Advertisement
Guest User

Untitled

a guest
Mar 24th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import gnupg
  2. from pprint import pprint
  3. class keys(object):
  4. self = []
  5. self.gpg = gnupg.GPG(gnupghome='/home/anon/.gnupg')
  6. def listkeys(self):
  7. public_keys = self.gpg.list_keys()
  8. private_keys = self.gpg.list_keys(True)
  9. print 'public keys:'
  10. pprint(public_keys)
  11. print 'private keys:'
  12. pprint(private_keys)
  13. print 'resumen:'
  14. #falta hacer un buscador
  15. def encrytar(self, a, b):
  16. unencrypted_string = a
  17. encrypted_data = self.gpg.encrypt(unencrypted_string, b)
  18. encrypted_string = str(encrypted_data)
  19. print 'ok: ', encrypted_data.ok
  20. print 'status: ', encrypted_data.status
  21. print 'stderr: ', encrypted_data.stderr
  22. print 'unencrypted_string: ', unencrypted_string
  23. print 'encrypted_string: ', encrypted_string
  24. return encrypted_string
  25. def descrytar(self, a, b, c):
  26. unencrypted_string = a
  27. encrypted_data = self.gpg.encrypt(unencrypted_string, b)
  28. encrypted_string = str(encrypted_data)
  29. decrypted_data = self.gpg.decrypt(encrypted_string, passphrase=c)
  30. print 'ok: ', decrypted_data.ok
  31. print 'status: ', decrypted_data.status
  32. print 'stderr: ', decrypted_data.stderr
  33. print 'decrypted string: ', decrypted_data.data
  34. return decrypted_data.data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement