pycrypto

https://pypi.org/project/pycrypto/

pycryptodome

https://pypi.org/project/pycryptodome/ [Unix] https://pypi.org/project/pycryptodomex/ [Windows]

  1. import json
  2. try:
  3. from Cryptodome.Cipher import AES
  4. from Cryptodome.Random import get_random_bytes
  5. except ImportError:
  6. from Crypto.Cipher import AES
  7. from Crypto.Random import get_random_bytes
  8. key = get_random_bytes(16)
  9. iv = get_random_bytes(16)
  10. print(f'key: {key}')
  11. print(f'iv: {iv}')
  12. data = {'data': [i for i in range(10)], 'msg': 'success'}
  13. message = json.dumps(data)
  14. print(message.encode())
  15. cipher = AES.new(key, AES.MODE_EAX, iv)
  16. enc_message = cipher.encrypt(message.encode())
  17. print(enc_message)
  18. cipher = AES.new(key, AES.MODE_EAX, iv)
  19. dec_message = cipher.decrypt(enc_message)
  20. print(dec_message.decode())

cryptography

https://pypi.org/project/cryptography/


crypto-js

https://www.npmjs.com/package/crypto-js https://cryptojs.gitbook.io/docs/

image.png

aes-js

https://github.com/ricmoo/aes-js