2

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!

1
  • Just use RNCryptor Commented Apr 21, 2017 at 18:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.