29 May 2013

python list, dict, tuple

>>> list = ['satu', 'dua', 333, 456546, 'infinite']
>>> print list[1]
>>> list
['satu', 'dua', 333, 456546, 'infinite']
ref >> http://www.tutorialspoint.com/python/python_lists.htm

>>> my_tuples = 'satu', 'dua', 333, 'infinite'
>>> my_tuples[1]
>>> my_tuples
('satu', 'dua', 333, 'infinite')
ref >>> http://www.tutorialspoint.com/python/python_tuples.htm

>>> dict = {'Alice': '2341', 'Beth': '9102', 'Cecil': '3258'}
>>> dict['Beth']
>>> dict
{'Alice': '2341', 'Beth': '9102', 'Cecil': '3258'}

ref >>> http://www.tutorialspoint.com/python/python_dictionary.htm

python pgp

$ sudo apt-get install python-pip
$ sudo pip install python-gnupg

ref >>> http://www.gefira.pl/blog/2011/04/11/securing-sec-walls-secrets-with-gnupg-and-python-gnupg/

import gnupg

gpg = gnupg.GPG(gnupghome='/home/testgpguser/gpghome')
with open('my-encrypted.txt.gpg', 'rb') as f:
    status = gpg.decrypt_file(f, passphrase='my passphrase', output='my-decrypted.txt')

print 'ok: ', status.ok
print 'status: ', status.status
print 'stderr: ', status.stderr
ref >> http://www.saltycrane.com/blog/2011/10/python-gnupg-gpg-example/

27 May 2013

python senarai method



tipu helai gpg

senarai public keys:
  gpg --list-keys

senarai private keys:
  gpg --list-secret-keys

decrypt file:
  gpg -o outputfile -d myencrypted.file.asc

ref>>  http://irtfweb.ifa.hawaii.edu/~lockhart/gpg/


to import a public key:
gpg --import public.key

This adds the public key in the file "public.key" to your public key ring.

to import a private key:
gpg --allow-secret-key-import --import private.key

This adds the private key in the file "private.key" to your private key ring. There's a note (*) at the bottom explaining why you may want to do this.

to delete a public key (from your public key ring):
gpg --delete-key "User Name"
This removes the public key from your public key ring.
NOTE! If there is a private key on your private key ring associated with this public key, you will get an error! You must delete your private key for this key pair from your private key ring first.

to delete an private key (a key on your private key ring):
gpg --delete-secret-key "User Name"
This deletes the secret key from your secret key ring.

To list the keys in your public key ring:
gpg --list-keys

To list the keys in your secret key ring:
gpg --list-secret-keys

To generate a short list of numbers that you can use via an alternative method to verify a public key, use:
gpg --fingerprint > fingerprint
This creates the file fingerprint with your fingerprint info.