From ca244853659595ab52de897f06dc8b155e59619f Mon Sep 17 00:00:00 2001 From: Ibnu Dzumirrotin <51980747+ibnudz@users.noreply.github.com> Date: Wed, 5 Oct 2022 16:38:01 +0800 Subject: [PATCH] principle of caesar cipher --- caesar_cipher.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 caesar_cipher.py diff --git a/caesar_cipher.py b/caesar_cipher.py new file mode 100644 index 0000000..4702692 --- /dev/null +++ b/caesar_cipher.py @@ -0,0 +1,25 @@ +# A python program to illustrate Caesar Cipher Technique +def encrypt(text, s): + result = "" + + # traverse text + for i in range(len(text)): + char = text[i] + + # Encrypt uppercase characters + if (char.isupper()): + result += chr((ord(char) + s - 65) % 26 + 65) + + # Encrypt lowercase characters + else: + result += chr((ord(char) + s - 97) % 26 + 97) + + return result + +# Modify this s variable to change shifted secret message +s = 4 +text = input("Input secret words : ") + +print("Text : " + text) +print("Shift : " + str(s)) +print("Cipher: " + encrypt(text, s)) \ No newline at end of file