GPG - encryption for the masses Source

1---
2title: 'GPG - encryption for the masses'
3date: '2007-05-04'
4published_at: '2007-05-04T12:51:00.001+10:00'
5tags: ['crypto', 'programming', 'python']
6author: 'Gavin Jackson'
7excerpt: 'Some handy usage information on how to use Gnu Privacy Guard (GPG) - an open source implementation of PGP: gpg --gen-key gpg --output revoke.asc --gen-revoke toms_key gpg --list-keys gpg --output publ...'
8updated_at: '2007-05-08T13:50:10.903+10:00'
9legacy_url: 'http://www.gavinj.net/2007/05/gpg-encryption-for-masses.html'
10---
11
12Some handy usage information on how to use Gnu Privacy Guard (GPG) - an open source implementation of PGP:
13
14gpg --gen-key gpg --output revoke.asc --gen-revoke toms_key gpg --list-keys gpg --output public_key.gpg --export test_user@nowhere.com (binary) gpg --armor --output tom.gpg --export test_user@nowhere.com gpg --import another_users_public_key.gpggpg --output doc gpg --encrypt --recipient another_user@somewhere.net doc.txt gpg --output doc.txt --decrypt doc.gpg
15
16I've also been playing with the python-gnupginterface python module, again looks pretty easy to implement - the following code simply encrypts a file with a passphrase:
17
18import GnuPGInterface... #Run file through gpg passphrase = "This is the passphrase" input = open("filename","r") output = open("filename.gpg", "w") gnupg = GnuPGInterface.GnuPG() gnupg.options.armor = 1 gnupg.options.meta_interactive = 0 gnupg.options.extra_args.append('--no-secmem-warning') p1 = gnupg.run(['--symmetric'], create_fhs=['passphrase'], attach_fhs={'stdin': input, 'stdout': output}) p1.handles['passphrase'].write(passphrase) p1.handles['passphrase'].close() p1.wait() print "File has been encrypted (gpg)"
19
20
21