gpg --gen-key
Choose the default options for the following first three questions
What kind of key? RSA and RSA
What keysize? 2048
Key is valid for? 0 (Does not expire)
It will ask for confirmation about the last question. Type y
Then give
Real name: HSC Blinder (Use your name instead)
Email: [email protected] (Use your email instead)
Comment:
It will ask if the USER-id it generates is Okay, press O.
Enter passphrase twice to lock the private key
This will generate the public/private key pair.
gpg --armor --export [email protected] > blinder_pubfile.asc
Replace [email protected] with the email address you gave while generating the key, and redirect to an appropriate filename which helps Rachel to keep track of whose key it is.
gpg --gen-key
Choose the default options for the following first three questions
What kind of key? RSA and RSA
What keysize? 2048
Key is valid for? 0 (Does not expire)
It will ask for confirmation about the last question. Type y
Then give:
Real name:
Email:
Comment:
It will ask if the USER-id it generates is Okay, press O.
Enter passphrase twice to lock the private key
This will generate your own public/private key pair. Then we have to import Jim's public key.
gpg --import blinder_pubfile.asc
gpg --edit-key "HSC Blinder"
Check the fingerprint using the command
gpg> fpr
Then sign the key if the fingerprint matches
gpg> sign
You will have to enter your passphrase for your private file. Now Jim's public key would be verified and trustworthy.
import numpy as np
import pyfits
import gnupg
import getpass
def FITS_to_PGP(message):
"""
Turns a string stored into an FITS comment back into a proper
PGP message
"""
s = "-----BEGIN PGP MESSAGE-----\n\n"
s += message
s += "\n-----END PGP MESSAGE-----\n"
return s
# This is the function which you will use to decrypt the string
def decrypt_string(encrypted_string):
string = getpass.getpass(prompt="Enter passphrase to unlock the private key:\n")
decrypted_data = gpg.decrypt(encrypted_string, passphrase=string)
print 'ok: ', decrypted_data.ok
print 'status: ', decrypted_data.status
print 'stderr: ', decrypted_data.stderr
print 'Decrypted string (additive m value for the catalog): ', decrypted_data.data
return decrypted_data.data
fnames = [ "GAMA09H_blinded_test11_0.fits.gz", "GAMA09H_blinded_test11_1.fits.gz", "GAMA09H_blinded_test11_2.fits.gz"]
gpg = gnupg.GPG()
for fname in fnames:
hdulist = pyfits.open(fname, memmap=True)
msg = hdulist[0].header["DM1"]
print float(decrypt_string(FITS_to_PGP(msg)))