repl.it
@imnotyouraura/

encode and decode caesar cipher

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
encode_decode_decide = input("Would you like to encode text (press 'E') or decode text (press 'D')")
if encode_decode_decide.lower() == "e":
  print("Encoding...")
  encode_input = input("Please enter the text you would like to encode: ")
  encode_shift = int(input("Please enter the shift: "))
  current_letter = 0
  alphabet = "abcdefghijklmnopqrstuvwxyz"
  looking_for = ""
  replacing_with = ""
  for current_letter in range(0, len(encode_input)):
    looking_for = encode_input[current_letter] 
    print(looking_for)
    alphabet_index = alphabet.find(looking_for)
    if  alphabet_index + encode_shift <= 25 - encode_shift:
      replacing_with = alphabet[alphabet_index + encode_shift]
    else:
      replacing_with = alphabet[alphabet_index - 25 + encode_shift]
    encode_input = encode_input.replace(looking_for, replacing_with, 1)
    current_letter = current_letter + 1
  print("Your encrypted string is: ", encode_input)
elif encode_decode_decide.lower() == "d":
  print("Decoding is not supported yet.")
  
else:
  print("Error - You did not provide a correct input.")
Fetching token
?