Package: fast-encrypt
fast-encryptfast-encryptis a comprehensive Python library that offers a variety of cryptographic methods to protect sensitive data simply and effectively.Table of contentsInstallationDocsExamplesCaesar's cipherMorse codeSubstitution cipherPipelineRSAContributingCreditsLicenseInstallationUsing pip:pipinstallfast-encryptDocsSee ourDocsfor comprehensive and detailed documentation onfast-encrypt. In the documentation, you will find in-depth explanations, usage examples, and additional resources to help you maximize your experience withfast-encrypt.This package offers classes for:Atbash cipherCaesar's cipherHomophonic substitutionMorse codePipeline of simple encryptorsRSA cryptosystemSubstitution cipherVigenère cipherExamplesCaesar's cipherTo encrypt some text usingCaesar's cipher, fist of all, you need import and instantiate theCaesarsCipherclass providing the shift for chars.fromfast_encryptimportCaesarsCipherencryptor=CaesarsCipher(1)# shift = 1Then, you'll be able to encrypt a text.plaintext='Hello World!'encrypted_text=encryptor.encrypt(plaintext)print(encrypted_text)Theencrypted_textwill be:Ifmmp Xpsme!To decrypt it's very simple.decrypted_text=encryptor.decrypt(encrypted_text)print(decrypted_text)Thedecrypted_textwill be:Hello World!Morse codeTo encrypt some text usingMorse code, fist of all, you need import and instantiate theMorseCodeclass.fromfast_encryptimportMorseCodeencryptor=MorseCode()Then, you'll be able to encrypt a text.plaintext='Hello World!'encrypted_text=encryptor.encrypt(plaintext)print(encrypted_text)Theencrypted_textwill be:.... . .-.. .-.. --- .-- --- .-. .-.. -..To decrypt it's very simple.decrypted_text=encryptor.decrypt(encrypted_text)print(decrypted_text)Thedecrypted_textwill be:HELLOWORLDSubstitution cipherTo encrypt some text usingsubstitution cipher, fist of all, you need import and instantiate theSubstitutionclass providing the alphabet for substitution.fromfast_encryptimportSubstitutionencryptor=Substitution('poiuytrewqlkjhgfdsamnbvcxz')# the alphabet for substitutionThen, you'll be able to encrypt a text.plaintext='Hello World!'encrypted_text=encryptor.encrypt(plaintext)print(encrypted_text)Theencrypted_textwill be:Eykkg Vgsku!To decrypt it's very simple.decrypted_text=encryptor.decrypt(encrypted_text)print(decrypted_text)Thedecrypted_textwill be:Hello World!PipelineYou can create a pipeline of simple encryptors, fist of all, you need import and instantiate thePipelineclass providing the list of simple encryptors.fromfast_encryptimport(Pipeline,CaesarsCipher,Substitution,MorseCode)pipeline=Pipeline([CaesarsCipher(3),Substitution('mnbvcxzlkjhgfdsapoiuytrewq'),MorseCode()])Then, you'll be able to encrypt a text.plaintext='Hello World!'encrypted_text=pipeline.encrypt(plaintext)print(encrypted_text)Theencrypted_textwill be:.... .-.. ... ... --- --.- --- -.-- ... --..To decrypt it's very simple.decrypted_text=pipeline.decrypt(encrypted_text)print(decrypted_text)Thedecrypted_textwill be:HELLOWORLDRSAFor a more complex and secure way to encrypt your data, you can use ourRSAclass for theRSA cryptosystem.To encrypt some text using , fist of all, you need import and instantiate theRSAclass providing the key length in bits (default = 1024).fromfast_encryptimportRSAencryptor=RSA()# default key length = 1024Then, you must generate the public and private key (public key is used for encrypt a text, private is used for decrypt)public_key,private_key=encryptor.generate_keypair()Then, you'll be able to encrypt a text.plaintext='Hello World!'encrypted_text=encryptor.encrypt(public_key,plaintext)print(encrypted_text)Theencrypted_textwill can be:1485228768820288706400698504222851526198153333611564433069219712708655679297610713312684847266463375809614570944...The three dots means the result own more numbers.To decrypt it's very simple.decrypted_text=encryptor.decrypt(private_key,encrypted_text)print(decrypted_text)Thedecrypted_textwill be:Hello World!ContributingYou may contribute in several ways like creating new features, fixing bugs, improving documentation and examples or translating any document here to your language. Find more information inCONTRIBUTING.md.LicenseMIT- Alberto Frigatto, 2024