# caesar cipher
def encrypt(text, shift):
    result = ""
    for ch in text:
        if ch.isupper():
            result = result + chr((ord(ch) - 65 + shift) % 26 + 65)
        elif ch.islower():
            result = result + chr((ord(ch) - 97 + shift) % 26 + 97)
        else:
            result = result + ch
    return result

def decrypt(text, shift):
    return encrypt(text, -shift)

msg = "Hello World"
key = 3
c = encrypt(msg, key)

print("message   :", msg)
print("shift     :", key)
print("encrypted :", c)
print("decrypted :", decrypt(c, key))
