mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-31 06:33:44 +00:00
fixed error (#3281)
this will fix code from randomly throwing `SystemExit: The affine cipher becomes weak when key B is set to 0. Choose different key` exception.
This commit is contained in:
parent
f164e11db4
commit
35eefac359
|
@ -94,7 +94,7 @@ def get_random_key():
|
|||
while True:
|
||||
keyA = random.randint(2, len(SYMBOLS))
|
||||
keyB = random.randint(2, len(SYMBOLS))
|
||||
if cryptomath.gcd(keyA, len(SYMBOLS)) == 1:
|
||||
if cryptomath.gcd(keyA, len(SYMBOLS)) == 1 and keyB % len(SYMBOLS) != 0:
|
||||
return keyA * len(SYMBOLS) + keyB
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user