cryptotools/examples/rsa.py
2026-01-11 09:19:22 +01:00

23 lines
357 B
Python

#!/usr/bin/env python3
from Cryptotools.Encryptions.RSA import RSA
rsa = RSA()
rsa.generateKeys(size=512)
e = rsa.e
d = rsa.d
n = rsa.n
s = "I am encrypted with RSA"
print(f"plaintext: {s}")
encrypted = rsa.encrypt(s)
# Encrypt data
# print(f"ciphertext: {encrypted}")
# We decrypt
plaintext = rsa.decrypt(encrypted)
print(f"Plaintext: {plaintext}")