From 14ce2ed5c69ee5ce4885a56b331ae8d684a9dba0 Mon Sep 17 00:00:00 2001 From: Bill Buchanan Date: Thu, 25 Feb 2021 19:14:32 +0000 Subject: [PATCH] Update c_02.py --- unit05_key_exchange/src/c_02.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/unit05_key_exchange/src/c_02.py b/unit05_key_exchange/src/c_02.py index 7c8caad..0d19eb8 100644 --- a/unit05_key_exchange/src/c_02.py +++ b/unit05_key_exchange/src/c_02.py @@ -1,22 +1,19 @@ import sys -import random p=11 def getG(p): for x in range (1,p): - rand = x - exp=1 - next = rand % p + rand = x + exp=1 + next = rand % p - while (next <> 1 ): - next = (next*rand) % p - exp = exp+1 - + while (next != 1 ): + next = (next*rand) % p + exp = exp+1 + if (exp==p-1): + print (rand) - if (exp==p-1): - print rand - -print getG(p) +print (getG(p))