Created
November 14, 2017 15:04
-
-
Save hzshang/616c51c25096aa33cce6d4051aad350b to your computer and use it in GitHub Desktop.
mod inverse for RSA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ext_Euclid(n,m): | |
if (m == 0): | |
return 1, 0 | |
else: | |
x, y = ext_Euclid(m, n%m) | |
x, y = y, (x -(n//m)*y) | |
return x, y | |
def mod_inverse(e,n): | |
x,y=ext_Euclid(e,n) | |
return (x+n)%n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment