repl.it
@AllenLi1/

RSA Decryption Key Finder

Python 2.7

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from math import floor
print("RSA Decryption Key Finder")

unaccepted = True
r = []
t = [0, 1]
s = [0]
p = 0
q = 0
e = 0
while(unaccepted == True):
    try:
        p = int(input("Enter p: "))
        q = int(input("Enter q: "))
        e = int(input("Enter e: "))
        unaccepted = False
    except:
        print("Please enter a number.")
phi = (p-1)*(q-1)
r.append(phi)
r.append(e)
index = 1
while r[index] != 1:
    s.append(floor(r[index-1]/r[index]))
    r.append(r[index-1] - (r[index]*s[index]))
    t.append(t[index-1] - (t[index]*s[index]))
    index += 1
key = int(t[index])
while key < 0:
  key += phi
while key > 0:
  key -= phi
print("The decryption key (d) is: " + str(key))


                 
Fetching token
?