filmov
tv
How to Code an Encoder and Decoder in Python!

Показать описание
In this video, I show you how to program your own A1-Z26 Cypher encoder and decoder so you can send encoded messages. You could also use this as a baseline to make more elaborate encoders and decoders such as making all the letters into prime numbers and multiplying them by other prime numbers, this is also the basis for modern military encryption.
The Code (so you don't have to):
alphabet = ['', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z', ' ', '!']
while True:
hello = input("\nCode Maker and breaker:\n1. Encode a sentence\n2. Decode a sentence\n9. Exit\n: ")
if hello == '1':
word = input("Input a sentence to Incode: ")
incode = list(word)
count = (len(incode))
timecount = 0
for count in incode:
print(code, "", end='')
timecount = timecount + 1
elif hello == "2":
cistring = input("Input a sentence to decode: ")
string = ""
for char in data:
char = chr(int(char) + 96)
if char == '{':
print(" ", end='')
elif char == "|":
print("!", end='')
else:
string += char
print(char, end='')
elif hello == '9':
print("Thanks for using Code maker and Breaker, have a good day")
break
else:
print("404 error, command not found. Try again using 1, 2 or 9")
The Code (so you don't have to):
alphabet = ['', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z', ' ', '!']
while True:
hello = input("\nCode Maker and breaker:\n1. Encode a sentence\n2. Decode a sentence\n9. Exit\n: ")
if hello == '1':
word = input("Input a sentence to Incode: ")
incode = list(word)
count = (len(incode))
timecount = 0
for count in incode:
print(code, "", end='')
timecount = timecount + 1
elif hello == "2":
cistring = input("Input a sentence to decode: ")
string = ""
for char in data:
char = chr(int(char) + 96)
if char == '{':
print(" ", end='')
elif char == "|":
print("!", end='')
else:
string += char
print(char, end='')
elif hello == '9':
print("Thanks for using Code maker and Breaker, have a good day")
break
else:
print("404 error, command not found. Try again using 1, 2 or 9")
Комментарии