From cc005746f64292161efafe90da654ad0adcf1f06 Mon Sep 17 00:00:00 2001 From: samuelIkoli Date: Wed, 23 Oct 2024 14:00:18 +0100 Subject: [PATCH] finished cryptic algorithm --- caeser_cipher.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 caeser_cipher.py diff --git a/caeser_cipher.py b/caeser_cipher.py new file mode 100644 index 00000000..ce96cc50 --- /dev/null +++ b/caeser_cipher.py @@ -0,0 +1,15 @@ +def caesarCipherEncryptor(string, key): + shiftValue = key % 26 + newString = "" + for char in string: + unicodeValue = ord(char) + shiftValue + if unicodeValue <= 122: + newString += chr(unicodeValue) + else: + newString += chr(96 + unicodeValue % 122) + return newString + +str = input('Input the message to be encrypted: ') +key = int(input('Input the number of shifts (key): ')) + +print('The encrypted message is:', caesarCipherEncryptor(str, key)) \ No newline at end of file