Commits

Anonymous committed 35f2d51

Better description of extended_gcd changes in comments

Comments (0)

Files changed (1)

     y = 1
     lx = 1
     ly = 0
-    la = a
-    lb = b                             #Remember modulus (to remove negs)
+    oa = a                             #Remember original a/b to remove 
+    ob = b                             #negative values from return results
     while b != 0:
         q = long(a/b)
         (a, b)  = (b, a % b)
         (x, lx) = ((lx - (q * x)),x)
         (y, ly) = ((ly - (q * y)),y)
-    if (lx < 0): lx += lb              #No Negative return values
-    if (ly < 0): ly += la
+    if (lx < 0): lx += ob              #If neg wrap modulo orignal b
+    if (ly < 0): ly += oa              #If neg wrap modulo orignal a
     return (a, lx, ly)
 
 # Main function: calculate encryption and decryption keys