Extended Euclidean Algorithm

 I was learning new cryptography topics for my college project and then I came across this amazing concept EXTEND EUCLIDEAN ALGORITHM (EEA)

EEA is used in decrypting RSA.

Following is the extract of EEC => 







Following is the python code for finding bezout's numbers => 

a = int(input("Enter A => "))
b = int(input("Enter B => "))

r1 = a
r2 = b
q = int(r1/r2)
r = r1%r2

s1 = 1
s2 = 0
s = s1 - q*s2

t1 = 0
t2 = 1
t = t1 - q*t2

while (1):
    r1 = r2
    r2 = r
    if (r2 == 0):
        s1 = s2
        t1 = t2
        break
    q = int(r1/r2)
    r = r1 % r2

    s1 = s2
    s2 = s
    s = s1 - q*s2

    t1 = t2
    t2 = t
    t = t1 - q*t2

print(r1,s1,t1)


Enter A => 60 Enter B => 36 12 -1 2

Comments

Popular posts from this blog

3 MAPPING TECHNIQUES

VIRTUAL MEMORY

ADJACENT MATRIX