diff --git a/Programs/P40_CipherText.py b/Programs/P40_CipherText.py index 3733f43..e092f31 100644 --- a/Programs/P40_CipherText.py +++ b/Programs/P40_CipherText.py @@ -11,7 +11,10 @@ def encrypt(message, key): if chars in LETTERS: num = LETTERS.find(chars) num += key - encrypted += LETTERS[num] + if num>25: + num=num%25 + num=num-1 + encrypted =encrypted + LETTERS[num] return encrypted @@ -21,8 +24,11 @@ def decrypt(message, key): for chars in message: if chars in LETTERS: num = LETTERS.find(chars) - num -= key - decrypted += LETTERS[num] + if num>25: + num=num%25 + num=num-1 + num = num -key + decrypted =decrypted+LETTERS[num] return decrypted