Package: encryptutils
EncryptUtilsA small encrypting/decrypting toolkit which includes support for text and files.Table of contentsBack to topTable of contentsInstallationUsing pipUnix/mac/linuxWindowsUsing git cloneUnix/mac/linuxWindowsUsageEncrypting textDecrypting textEncrypting a fileDecrypting a fileEncrypting multiple filesDecrypting multiple filesInstallationYou can install EncryptUtils in two methods:UsingpipTo install this package using pip, simply run the following command:Unix/mac/linux:pip3installencryptutilsWindows:pip install encryptutilsUsinggit cloneWARNING: THIS SECTION IS A WORK IN PROGRESSYou can also install EncryptUtils by runninggit clone.Unix/mac/linux:gitclonehttps://github.com/tinkering-townsperson/encryptutilscdencryptutils
chowninstall.sh755./installWindows:git clone https://github.com/tinkering-townsperson/encryptutils
cd encryptutils
.\installUsageEncrypting textTo encrypt text in the form of a string or byte-like object, you can use theencrypt()method.encryptingMyPyPIToken.pyfromencryptutilsimport*frompathlibimportPathfromcryptography.fernetimportFernetmyKey=Fernet.generate_key()myPyPIToken="pypi-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"encrypt(myPyPIToken,myKey)Decrypting textTo decrypt text, use thedecrypt()methoddecryptingMyPyPITokenBecauseINeedItNow.pyfromencryptutilsimport*frompathlibimportPathfromcryptography.fernetimportFernetmyEncryptedPyPIToken="niQaqhetJzLHW56cFaDQuG6kcLizYicrdth4xeiruyg=\n\ngAAAAABiw2yHQkEclSVxSyqLuw1EKoAKErh_pLCMKsC2y-udbPm6T5Q96YwONikdPrE6WTf--XS-_qvs3vx95OdbTnATtfNPma0XBesR9O9ftZdnx3leSYhmK2Nq3oP2nB_u3xACfK09y0QmTiHAbA2BlXo-2vnbm-bb5JHZzzMm72jCHw19uuWWQANTbIi38b3VTpt3UHcf1rEu_I-GRA7LXwxQ9Djk4Ueq3mHykTXqs8duM9hK461ZLNr6AoskbCK0On9LDa6ZDoOULjnDmKvC35Ai8e3-zcVM4YHEoxgaRmZbTHhtUM0="decrypt(myPyPIToken)You may have noticed that you do not need to providedecrypt()with a key. This is because when you encrypt files withencrypt()the method concatenates(adds) the key to the encrypted data.decrypt()splits the key and data apart, and uses the key to decrypt the encrypted data!Encrypting a fileTo encrypt a file, simply import it in a python fileorthe interactive prompt. Here is an example:encryptMyPasswords.pyfromencryptutilsimport*frompathlibimportPathfromcryptography.fernetimportFernetmyKey=Fernet.generate_key()myPasswordsPath=Path("C:\\Users\\AfterNoonPM\\myPasswords.csv")encrypt_file(myPasswordsPath,myKey)Decrypting a fileDecrypting a file is more of the same story:decryptMyPasswordsBecauseIForgotThemOops.pyfromencryptutilsimport*frompathlibimportPathmyForgottenPasswordsPath=Path("C:\\Users\\AfterNoonPM\\myPasswords.csv")decrypt_file(myPasswordsPath)You may have noticed that you do not need to providedecrypt_file()with a key. The reason for this is almost the same as mentionedhere.Encrypting multiple filesEncrypting multiple files is almost the same as encrypting one, with a few minor differences.encryptingMyPictures.pyfromencryptutilsimport*frompathlibimportPathfromcryptography.fernetimportFernetmyKey=Fernet.generate_key()myPicture1=Path("C:\\Users\\AfterNoonPM\\Pictures\\myPicture1.png")myPicture2=Path("C:\\Users\\AfterNoonPM\\Pictures\\myPicture2.png")myPicture3=Path("C:\\Users\\AfterNoonPM\\Pictures\\myPicture3.png")myPicture4=Path("C:\\Users\\AfterNoonPM\\Pictures\\myPicture4.png")encrypt_files((myPicture1,myPicture2,myPicture3,myPicture4),myKey)Decrypting multiple filesDecrypting multiple files is almost the same.decryptingMyPreciousPictures.pyfromencryptutilsimport*frompathlibimportPathfromcryptography.fernetimportFernetmyKey=Fernet.generate_key()myEncryptedPicture1=Path("C:\\Users\\AfterNoonPM\\Pictures\\myPicture1.png")myEncryptedPicture2=Path("C:\\Users\\AfterNoonPM\\Pictures\\myPicture2.png")myEncryptedPicture3=Path("C:\\Users\\AfterNoonPM\\Pictures\\myPicture3.png")myEncryptedPicture4=Path("C:\\Users\\AfterNoonPM\\Pictures\\myPicture4.png")decrypt_files((myPicture1,myPicture2,myPicture3,myPicture4))And not including the key still has the same reason ashere