# What is a Cipher?

## A secret or disguised way of writing # Programming a Cipher

``key = 13``
``message = input("What is your message?")``

``for i in message:``
``    ascii_value = ord(i)``
``    ascii_value = ascii_value + key``
``    new_letter = chr(ascii_value)``
``    print(new_letter, end = "")``

# Programming a Decoder

``decode = ""``

``for j in range(1,27):``
``    for i in decode:``
``        ascii_value = ord(i)``
``        ascii_value = ascii_value - j``
``        new_letter = chr(ascii_value)``
``        print(new_letter, end = "")``
``    print()``

# Final Product

``##Cipher``
``from random import randint``
``key = randint(1,27)``
``message = input("What is your message?")``

``for i in message:``
``    ascii_value = ord(i)``
``    if (ascii_value >= 65 and ascii_value <= 90) or (ascii_value >= 97 and ascii_value <= 122): ``
``        if ascii_value + key > 90 and ascii_value <= 90:``
``            ascii_value = (ascii_value + key - 90) + 64``
``        elif ascii_value + key > 122:``
``            ascii_value = (ascii_value + key - 122) + 96``
``        else:``
``            ascii_value = ascii_value + key``
``        new_letter = chr(ascii_value)``
``        print(new_letter, end = "")``
``    else:``
``        print(i , end = "")``

``def decode(message):``
``    for j in range(1, 27):``
``        key = j``
``        for i in message:``
``            ascii_value = ord(i)``
``            if (ascii_value >= 65 and ascii_value <= 90) or (ascii_value >= 97 and ascii_value <= 122): ``
``                if ascii_value - key < 65:``
``                    ascii_value = 91 - (65 - (ascii_value - key))``
``                elif ascii_value - key < 97 and ascii_value >= 97:``
``                    ascii_value = 123 - (97 - (ascii_value - key))``
``                else:``
``                    ascii_value = ascii_value - key``
``                new_letter = chr(ascii_value)``
``                print(new_letter, end = "")``
``            else:``
``                print(i , end = "")``
``        print()``