need pycryptodome

Hashing

hashSha256[source]

hashSha256(data:bytes, salt:Optional[bytes]=b'')

%%time
hashSha256(b'test')
CPU times: user 8 µs, sys: 2 µs, total: 10 µs
Wall time: 14.5 µs
b'\x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08'

AES

Encrypt

encryptAes[source]

encryptAes(key:bytes, data:bytes)

note that key has to be 16 bits long response: cipherText in bytes

key = b'testtesttesttest'
data = b'test'
password = b'testpw'
ciphertext, nonce = encryptAes(key,data)
print(ciphertext, nonce)
b'\xd9\x96\xce\xfd' b'wX7\xf7ZT\xcee\xab==\x99\x16\xf79\x9f'

Encrypt with password

encryptPasswordAes[source]

encryptPasswordAes(password:bytes, data:bytes)

pwData, pwNonce = encryptPasswordAes(password, data = b'this is a very important data')
print(pwData, pwNonce)
b"I'\x16'\xa3\x86\x95`\xf7k\x9f\xab\x92?z\xb1z=\x97\xa85\\U\x98\xd3@0\xbdr" b'jDg\xdbBm\x98\xd11[\xd16h`\xb4\xc2'

Decrypt

decryptAes[source]

decryptAes(key:bytes, ciphertext:bytes, nonce:bytes)

decryptAes(key, ciphertext, nonce)
b'test'

Decrypt password

decryptPasswordAes[source]

decryptPasswordAes(ciphertext:bytes, password:bytes, nonce:bytes)

decryptPasswordAes(pwData, password, pwNonce)
b'this is a very important data'