From 35eefac35917ad3b2b90a190929bf131ea13427b Mon Sep 17 00:00:00 2001 From: NAVEEN S R <56086391+nkpro2000sr@users.noreply.github.com> Date: Wed, 14 Oct 2020 15:23:37 +0530 Subject: [PATCH] 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. --- ciphers/affine_cipher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciphers/affine_cipher.py b/ciphers/affine_cipher.py index 70e695de5..1b1943a37 100644 --- a/ciphers/affine_cipher.py +++ b/ciphers/affine_cipher.py @@ -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