Files
2025-06-02 19:35:30 +02:00

31 lines
637 B
Python

#!/usr/bin/env python3
from Cryptodome.PublicKey import RSA
#kth root of the number n
def iroot(k, n):
u, s = n, n+1
while u < s:
s = u
t = (k-1) * s + n // pow(s, k-1)
u = t // k
return s
if __name__ == '__main__':
e = 3
# d = rsa_keypair.d
n = 388435672474892257936058543724812684332943095105091384265939
m = b'A'*8
m_int = int.from_bytes(m,byteorder='big')
c = pow(m_int,e,n)
decrypted_int = iroot(e, c)
print(decrypted_int)
print(decrypted_int.to_bytes(decrypted_int.bit_length() // 8 +1, byteorder='big').decode())
dec = pow(c, 1/3)
print(dec)