From 310e3b3b2ab15aebbcbda48cf435838334792037 Mon Sep 17 00:00:00 2001 From: Alexander Munch-Hansen Date: Wed, 24 Feb 2021 00:22:47 +0100 Subject: [PATCH] Fixed some comments, removed some useless code --- main.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/main.py b/main.py index 9a7712e..4302e7a 100644 --- a/main.py +++ b/main.py @@ -37,7 +37,7 @@ def extendedEuclid(a, b): def modInv(a, m): """returns the multiplicative inverse of a in modulo m as a positive value between zero and m-1""" - # notice that a and m need to co-prime to each other. + # notice that a and m need to be co-prime to each other. if coPrime([a, m]): linearCombination = extendedEuclid(a, m) return linearCombination[1] % m @@ -58,18 +58,6 @@ def extractTwos(m): return i, m >> i -def int2baseTwo(x): - """x is a positive integer. Convert it to base two as a list of integers - in reverse order as a list.""" - # repeating x >>= 1 and x & 1 will do the trick - assert x >= 0 - bitInverse = [] - while x != 0: - bitInverse.append(x & 1) - x >>= 1 - return bitInverse - - def millerRabin(n, k): """ Miller Rabin pseudo-prime test @@ -169,7 +157,7 @@ def decrypt(secret, modN, d, blockSize): if __name__ == '__main__': - n, e, d = newKey(10 ** 100, 10 ** 101, 50) + n, e, d = newKey(2**40, 2 ** 41, 20) message = 35274764 print("original message is {}".format(message))