Created
September 17, 2020 16:43
-
-
Save nolifeasian24-7/b921ed5f60c0a957726cd72cca09637e to your computer and use it in GitHub Desktop.
Cieser cipher in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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