Skip to content

Instantly share code, notes, and snippets.

@nolifeasian24-7
Created September 17, 2020 16:43
Show Gist options
  • Save nolifeasian24-7/b921ed5f60c0a957726cd72cca09637e to your computer and use it in GitHub Desktop.
Save nolifeasian24-7/b921ed5f60c0a957726cd72cca09637e to your computer and use it in GitHub Desktop.
Cieser cipher in python
def start():
normaltext = input('enter your word/phrase: ')#gahter the string
normaltext1 = normaltext.lower()#convert to lowercase
Alphabets = "abcdefghijklmnopqrstuvwxyz"
shift = int(input('by how much do you want to shift'))#how much the user wants to shift by
cipher =' '
TypeInput = input("choose type + or -")#shifting left or right (names for this i forgot)
if TypeInput == "+":#condition "+"
for d in normaltext1:
if d in Alphabets:
cipher += Alphabets [(Alphabets . index (d)+shift )%(len(Alphabets))]#runs through Alphabets and searches for the index based on shift
else:
for d in normaltext1:
if d in Alphabets:
cipher += Alphabets [(Alphabets . index (d)-shift )%(len(Alphabets))]#same as line 12 but reversed
print('Your cipher code is: ' + cipher)#print the damn thing
while True:
start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment