Advertisement
Guest User

Untitled

a guest
Sep 5th, 2024
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. Thanks for your answer. I think that according to the devs on cryptography's github, this code uses AES-256:
  2.  
  3. ```python
  4. import os
  5.  
  6. from cryptography.hazmat.primitives.ciphers.aead import AESGCM
  7.  
  8. to_encrypt = b'secret message'
  9. k = AESGCM.generate_key(256)
  10. iv = os.urandom(32)
  11. a = AESGCM(k)
  12.  
  13. encrypted = iv + a.encrypt(iv, to_encrypt, None)
  14. print(f'{k = }\n{encrypted = }')
  15.  
  16. assert to_encrypt == a.decrypt(encrypted[:32], encrypted[32:], None)```
  17.  
  18. Is this code okay?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement