gpg = gnupg.GPG(gnupghome='/home/testgpguser/gpghome') unencrypted_string = 'Who are you? How did you get in my house?' encrypted_data = gpg.encrypt(unencrypted_string, 'testgpguser@mydomain.com') encrypted_string = str(encrypted_data) print'ok: ', encrypted_data.ok print'status: ', encrypted_data.status print'stderr: ', encrypted_data.stderr print'unencrypted_string: ', unencrypted_string print'encrypted_string: ', encrypted_string
Decrypt String
1 2 3 4 5 6 7 8 9 10 11 12
import gnupg
gpg = gnupg.GPG(gnupghome='/home/testgpguser/gpghome') unencrypted_string = 'Who are you? How did you get in my house?' encrypted_data = gpg.encrypt(unencrypted_string, 'testgpguser@mydomain.com') encrypted_string = str(encrypted_data) decrypted_data = gpg.decrypt(encrypted_string, passphrase='my passphrase')