Skip to content

Commit 63c10b9

Browse files
authored
fixed error (TheAlgorithms#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.
1 parent 528552b commit 63c10b9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: ciphers/affine_cipher.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def get_random_key():
9494
while True:
9595
keyA = random.randint(2, len(SYMBOLS))
9696
keyB = random.randint(2, len(SYMBOLS))
97-
if cryptomath.gcd(keyA, len(SYMBOLS)) == 1:
97+
if cryptomath.gcd(keyA, len(SYMBOLS)) == 1 and keyB % len(SYMBOLS) != 0:
9898
return keyA * len(SYMBOLS) + keyB
9999

100100

0 commit comments

Comments
 (0)