crypto.py 594 B

1234567891011121314151617181920212223
  1. from Crypto import Random
  2. from Crypto.PublicKey import RSA
  3. from Crypto.Cipher import PKCS1_v1_5 as PKCS1_cipher
  4. with open('public.rsa') as f:
  5. key = f.read()
  6. public_key = RSA.import_key(key)
  7. public_cipher = PKCS1_cipher.new(public_key)
  8. with open('private.rsa') as f:
  9. key = f.read()
  10. private_key = RSA.import_key(key)
  11. private_cipher = PKCS1_cipher.new(private_key)
  12. # print(public_key.exportKey().decode('utf-8'))
  13. # random_generator = Random.new().read
  14. # rsa = RSA.generate(2048, random_generator)
  15. # private_key = rsa.exportKey()
  16. # print(private_key.decode('utf-8'))