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:
NAVEEN S R 2020-10-14 15:23:37 +05:30 committed by GitHub
parent f164e11db4
commit 35eefac359
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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