asym encryption working

This commit is contained in:
luke
2021-03-10 13:36:30 -05:00
parent 13e4698095
commit c1a86adcf5
11 changed files with 151 additions and 41 deletions

14
RSA/encrypt.py Normal file
View File

@@ -0,0 +1,14 @@
from Crypto.Cipher import PKCS1_OAEP as pk
from Crypto.PublicKey import RSA
key = RSA.import_key(open("publickey.pem", "r").read())
cipher = pk.new(key)
message = "attack at dawn"
encd = cipher.encrypt(bytes(message, "utf-8"))
print(encd)
dkey = RSA.import_key(open("privatekey.pem").read())
dcipher = pk.new(dkey)
dmessage = dcipher.decrypt(encd)
print(dmessage)