pypcp: started with decrypt

This commit is contained in:
TLINDEN
2014-12-22 19:48:36 +01:00
parent 3061192193
commit 87efb36e46
2 changed files with 78 additions and 13 deletions

View File

@@ -3,20 +3,28 @@
from pypcp import *
from pprint import pprint
# import secret key
zbobsec = open("../../tests/key-bobby-sec", "r").read()
bobsec = Key(encoded=zbobsec, passphrase="b")
#bobsec.dump()
# import public key
zalipub = open("../../tests/key-alicia-pub", "r").read()
alipub = PublicKey(encoded=zalipub)
#alipub.dump()
# always required
ctx = Context()
encrypted = ctx.encrypt(string="hello world", passphrase="x")
# symmetric encryption (self mode)
sencrypted = ctx.encrypt(string="hello world", passphrase="x", armor=True)
print sencrypted
# asymmetric encryption bob => alice
ctx.addkey(bobsec)
ctx.recipients(alipub)
encrypted = ctx.encrypt(string="hello world")
aencrypted = ctx.encrypt(string="hello world", armor=True, sign=False)
#print aencrypted
sclear = ctx.decrypt(string=sencrypted, passphrase="x")
print sclear