Skip to content

Commit

Permalink
fixed error (TheAlgorithms#3281)
Browse files Browse the repository at this point in the history
this will fix code from randomly throwing `SystemExit: The affine cipher becomes weak when key B is set to 0. Choose different key` exception.
  • Loading branch information
nkpro2000sr authored Oct 14, 2020
1 parent f164e11 commit 35eefac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ciphers/affine_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 35eefac

Please sign in to comment.