Rsa
Rsa
print(n)
print(phi)
e = 0 # public key
d = 0 # private key
# for e
for i in range(1, phi):
if (phi % i != 0) and (i != p) and (i != q):
e = i
break
print(f"E:{e}")
# for d
for i in range(1, phi):
x = (1 + (i * phi)) / e
# print(x)
f = x % 1 # to get the float value
print(f"D:{d}")
# encrypt
def encrypt(msg):
return pow(msg, e, n)
#decrypt
def decrypt(cipher):
return pow(cipher, d, n)
if e and d:
cipher = encrypt(message)
print(f"Cipher Text:{cipher}")
pt = decrypt(cipher)
print(f"Plain Text:{pt}")