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 == decrypted
The 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 (
12
random bytes) is used to create the256 bit
long encryption key from thepassword
usingpbkdf2
and10000
as iteration count. - The
plaintext
is encrypted usingaes-256-gcm
with the generated key and a12
bytes 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
base64
and returns it.
- It decodes the
base64
input to bytes - It slices this data into: password salt, initialization vector, ciphertext.
- The password salt and the
password
are used to generate the256 bit
long encryption key usingpbkdf2
and10000
as iteration count (same as in encryption process). - The ciphertext is decrypted using
aes-256-gcm
with 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.