Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def egcd(a, b):
- x,y, u,v = 0,1, 1,0
- while a != 0:
- q, r = b//a, b%a
- m, n = x-u*q, y-v*q
- b,a, x,y, u,v = a,r, u,v, m,n
- gcd = b
- return gcd, x, y
- def main():
- p = 31633324922152208667782365945327593684774069143774669661619572762724400715661831
- q = 36515984267977612350498121647561131263792046107668364547689126140974588406556229
- e = 65537
- ct = 3850399659456144909054023356222104703474998103430205103288738594544245075326232
- 52932642491630030372490846191037269295383730831605896115604912885466639330684242
- # compute n
- n = p * q
- # Compute phi(n)
- phi = (p - 1) * (q - 1)
- # Compute modular inverse of e
- gcd, a, b = egcd(e, phi)
- d = a
- print( "d: " + str(d) );
- # Decrypt ciphertext
- pt = pow(ct, d, n)
- print( "Message: " + str(pt) )
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment