Recently I want to port the original Javascript AES256 encryption code to Python, I've seen lots of posts (e.g. *1, *2) , but that's not I want.
I want a simple function without extra settings, only input the payload and key, output the encrypted/decrypted payload, corresponding to the below two functions.
function encrypt (payload, key) {
var cipher = crypto.createCipher('aes256', key)
var encryptedPayload = cipher.update(payload, 'utf8', 'hex')
encryptedPayload += cipher.final('hex')
return encryptedPayload
}
function decrypt (payload, key) {
const decipher = crypto.createDecipher('aes256', key)
let decryptedPayload = decipher.update(payload, 'hex', 'utf8')
decryptedPayload += decipher.final('utf8')
return decryptedPayload
}
I cannot find any solution to this. Does that mean this problem is difficult or the spec mismatch between Javascript and Python's library?
Or if I want to make it happened, can I contribute to PyCrypto or some open source?
Thanks!