asym encryption working
This commit is contained in:
14
RSA/encrypt.py
Normal file
14
RSA/encrypt.py
Normal 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)
|
||||
Reference in New Issue
Block a user