-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrsa.py
More file actions
25 lines (20 loc) · 769 Bytes
/
rsa.py
File metadata and controls
25 lines (20 loc) · 769 Bytes
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
from Crypto.Util.number import long_to_bytes
c = 606692285506838941840602456152941805058687761035977742885434270828366768350801130402690262903464242989622720049447625017
e = 65537
n = 833810193564967701912362955539789451139872863794534923259743419423089229206473091408403560311191545764221310666338878019
p = 863653476616376575308866344984576466644942572246900013156919
q = 965445304326998194798282228842484732438457170595999523426901
phi = (p-1)*(q-1) #mencari nilai phi
def abcd(a, b):
if a == 0:
return(b, 0, 1)
e, f, g = abcd(b%a, a)
return (e, g-(b//a) * f, f)
def modinv(a, m):
e, g, f = abcd(a, m)
if g != 1:
raise Exception('no mular inverse')
return g%m
d = modinv(e, phi)
m = pow(c,d,n)
print(long_to_bytes(m))