Speed Coding A Caesar Cipher In Python (Time lapse)

Veröffentlicht am: 25 Februar 2020
auf dem Kanal: R.K. Coding
72
1

This was originally a tutorial, but the audio quality was bad, so I turned it into a time lapse instead.

code:
def rotate_list_left(rotation_number, list):
rotated_list = list[:]

for i in range(rotation_number):
rotated_list.append(rotated_list[0])
del(rotated_list[0])

return rotated_list

def rotate_list_right(rotation_number, list):
rotated_list = list[:]

for i in range(rotation_number):
rotated_list.insert(0, rotated_list[len(rotated_list) - 1])
del(rotated_list[len(rotated_list) - 1])

return rotated_list

char_lower = list("abcdefghijklmnopqrstuvwxyz")
char_upper = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

while True:
instruction = input("ENCRYPT (E), DECRYPT (D), or STOP(S): ")

if (instruction == "S"):
print("DONE")
break


key = int(input("WHAT IS THE KEY: "))
message = input("MESSAGE: ")

output = ""

if (instruction == "E"):
for char in message:
if (char in char_lower):
index = char_lower.index(char)
rotated_list = rotate_list_left(key, char_lower)
output += rotated_list[index]

elif (char in char_upper):
index = char_upper.index(char)
rotated_list = rotate_list_left(key, char_upper)

output += rotated_list[index]

else:
output += char

elif (instruction == "D"):
for char in message:
if (char in char_lower):
index = char_lower.index(char)
rotated_list = rotate_list_right(key, char_lower)
output += rotated_list[index]

elif (char in char_upper):
index = char_upper.index(char)
rotated_list = rotate_list_right(key, char_upper)

output += rotated_list[index]

else:
output += char

else:
print("INVALID COMMAND: VALID COMMANDS ARE CAPITAL E FOR ENCRYPTION, CAPITAL D FOR DECRYPTION, OR CAPITAL S FOR STOPPING")


print(output)


Auf dieser Seite können Sie das Online-Video Speed Coding A Caesar Cipher In Python (Time lapse) mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer R.K. Coding 25 Februar 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 72 Mal angesehen und es wurde von 1 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!