28 lines
764 B
Python
28 lines
764 B
Python
|
import time
|
||
|
from Crypto.Hash import SHA256
|
||
|
from Crypto.PublicKey import RSA
|
||
|
from Crypto.Signature import PKCS1_v1_5
|
||
|
|
||
|
def rsa3072():
|
||
|
start = time.time()
|
||
|
key = RSA.generate(2048)
|
||
|
end = time.time()-start
|
||
|
with open('RSA3072_priv.pem','wb') as a:
|
||
|
a.write(key.exportKey('PEM'))
|
||
|
with open('RSA3072_pub.pem','wb') as b:
|
||
|
b.write(key.publickey().exportKey('PEM'))
|
||
|
print("Time spent RSA 3072 ", end)
|
||
|
|
||
|
def rsa7680():
|
||
|
start = time.time()
|
||
|
key = RSA.generate(7680)
|
||
|
end = time.time()-start
|
||
|
with open('RSA7680_priv.pem','wb') as c:
|
||
|
c.write(key.exportKey('PEM'))
|
||
|
with open('RSA7680_pub.pem','wb') as d:
|
||
|
d.write(key.publickey().exportKey('PEM'))
|
||
|
print("Time spent rsa7680 : ", end)
|
||
|
|
||
|
rsa3072()
|
||
|
rsa7680()
|