Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. from cryptography.fernet import Fernet
  2. key = Fernet.generate_key()
  3. key = b''
  4. input_file = 'test.txt'
  5. output_file = 'test.encrypted'
  6.  
  7. with open(input_file, 'rb') as f:
  8. data = f.read()
  9.  
  10. fernet = Fernet(key)
  11. encrypted = fernet.encrypt(data)
  12.  
  13. with open(output_file, 'wb') as f:
  14. f.write(encrypted)
  15.  
  16. "Fernet key must be 32 url-safe base64-encoded bytes."
  17. ValueError: Fernet key must be 32 url-safe base64-encoded bytes.
  18.  
  19. hello john with id no 345678 with phone no 12345678
  20. hello peter with id no 87654 with phone no 45678990
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement