teslariu

criptografia

May 15th, 2021
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. from cryptography.fernet import Fernet
  5.  
  6. # genero una clave secreta
  7. key = Fernet.generate_key()
  8.  
  9. # abro la clave
  10. f = Fernet(key)
  11.  
  12. # cifro el texto HOLA
  13. secreto = f.encrypt(b"HOLA")
  14.  
  15. # muestro el secreto
  16. print(secreto)
  17.  
  18. # lo decifro y lo muestro
  19. texto = f.decrypt(secreto)
  20.  
  21. print(texto)
Advertisement
Add Comment
Please, Sign In to add comment