from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_v1_5 as Cipher_PKCS1_v1_5
# generate private key
# key = RSA.generate(2048)
# f = open('mykey.pem','w')
# f.write(RSA.exportKey('PEM'))
# f.close()

# import public key
f = open('pubkey.pem','r')
o = RSA.importKey(f.read())

ptx = chr(17)
c = o.encrypt(ptx, 'x')[0]
print c.encode('hex')

x = Cipher_PKCS1_v1_5.new(o)
c = x.encrypt(ptx)
print c.encode('hex')

Referensi

results matching ""

    No results matching ""