Simple, secure encryption and decryption for Python 2.7 and 3
Simple Crypt encrypts and decrypts data. It has two functions, encrypt and decrypt:
from simplecrypt import encrypt, decrypt ciphertext = encrypt('password', plaintext) plaintext = decrypt('password', ciphertext)
That’s it. You can see the implementation on github.
You must also install pycrypto. Note that pycrypto has parts written in C so requires a full python install. On some unix systems that may mean adding a package like python-dev from your package manager.
In Python 3 the outputs from encrypt and decrypt are bytes. If you started with string input then you can convert the output from decrypt using .decode('utf8'):
mystring = decrypt('password', ciphertext).decode('utf8')
Later versions can decrypt data from previous versions, but data encrypted by later (major) versions cannot be decrypted by earlier code (instead, an error is raised asking the user to update to the latest version).