Simple script for Caesar Cipher in Python:

def encrypt(string, shift):

  cipher = ''
  for char in string:
    if char == ' ':
      cipher = cipher + char
    elif  char.isupper():
      cipher = cipher + chr((ord(char) + shift - 65) % 26 + 65)
    else:
      cipher = cipher + chr((ord(char) + shift - 97) % 26 + 97)

  return cipher

text = "Local Hack Day"
s = int(input("Shift: "))
print("Original string: ", text)
print("Encrypted string: ", encrypt(text, s))

Built With

Share this project:

Updates