Provides simple wrappers around Python cryptography module. It is secure by default and compatible with the easy-crypto node module.
from easycrypto import Crypto
plaintext = 'mysecretdata'
password = 'mypassword'
encrypted = Crypto.encrypt(password, plaintext)
decrypted = Crypto.decrypt(password, encrypted)
assert encrypted == decryptedThe library is only a thin wrapper of python's own cryptography module. It uses well known and battle tested encryption techniques. It provides a convenient wrapper around these functions, taking away the details of using encryption correctly. Feel free to explore the source!
- A random so called password salt (
12random bytes) is used to create the256 bitlong encryption key from thepasswordusingpbkdf2and10000as iteration count. - The
plaintextis encrypted usingaes-256-gcmwith the generated key and a12bytes long random initialization vector. The resulted ciphertext contains built-in integrity check as well. - To enable decryption, the following data is concatenated into a buffer: password salt, initialization vector, ciphertext.
- It encodes the whole buffer using
base64and returns it.
- It decodes the
base64input to bytes - It slices this data into: password salt, initialization vector, ciphertext.
- The password salt and the
passwordare used to generate the256 bitlong encryption key usingpbkdf2and10000as iteration count (same as in encryption process). - The ciphertext is decrypted using
aes-256-gcmwith the generated key and the initialization vector. During encryption the integrity of the data is also verified.
Please find us, we would love your feedback!
Tag your commit with x.y.z, then if all tests pass x.y.z version will be released on Pypi.