MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / checkKeys

Function checkKeys

ciphers/affine_cipher.py:24–32  ·  view source on GitHub ↗
(keyA, keyB, mode)

Source from the content-addressed store, hash-verified

22 return (keyA, keyB)
23
24def checkKeys(keyA, keyB, mode):
25 if keyA == 1 and mode == 'encrypt':
26 sys.exit('The affine cipher becomes weak when key A is set to 1. Choose different key')
27 if keyB == 0 and mode == 'encrypt':
28 sys.exit('The affine cipher becomes weak when key A is set to 1. Choose different key')
29 if keyA < 0 or keyB < 0 or keyB > len(SYMBOLS) - 1:
30 sys.exit('Key A must be greater than 0 and key B must be between 0 and %s.' % (len(SYMBOLS) - 1))
31 if cryptoMath.gcd(keyA, len(SYMBOLS)) != 1:
32 sys.exit('Key A %s and the symbol set size %s are not relatively prime. Choose a different key.' % (keyA, len(SYMBOLS)))
33
34def encryptMessage(key, message):
35 ''&#x27;

Callers 2

encryptMessageFunction · 0.85
decryptMessageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected