mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 20:00:58 +01:00
pypcp: started with decrypt
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user