Last active
December 10, 2020 16:08
-
-
Save bl4ckbo7/37fc801b48d4e4b9569b22f893c69248 to your computer and use it in GitHub Desktop.
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
#Finding Bezout's Identities using Inverse modulo algorithm - PoC | |
#let gcd(n,e) | |
#from ex + by = 1 | |
#x = e^(-1) mod n | |
#Author: bl4ckbo7 | |
#!/usr/bin/env python3 | |
e = eval(input("Enter the value of a: ")) | |
n = eval(input("Enter the value of b: ")) | |
d = eval(input("Enter the value of gcd: ")) | |
x, y, mod, d, e, n = 0, 0, 0, d//d, e//d, n//d | |
while mod != 1: | |
x+=1 | |
print( str(mod) + " = {0} * {1} % {2} ".format(e, x, n)) | |
mod = (e * x) % n | |
print("-"*50) | |
print("x = {0}, y = {1}".format(x, (d - (e * x)) // n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment