Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # custom digital encoder/decoder
- import time as t
- text_decode = 'Enter string to Decode...'
- text_encode = 'Type string to Encode...'
- numbers = { "a": "10110100",
- "b": "00000001",
- "c": "00000010",
- "d": "00000011",
- "e": "01011010",
- "f": "00000100",
- "g": "00000101",
- "h": "00000110",
- "i": "00000111",
- "j": "00001000",
- "k": "00001001",
- "l": "00001010",
- "m": "00001011",
- "n": "00001100",
- "o": "00001101",
- "p": "00001110",
- "q": "00001111",
- "r": "00010000",
- "s": "00010001",
- "t": "00010010",
- "u": "00010011",
- "v": "00010100",
- "w": "00010101",
- "x": "00010110",
- "y": "00010111",
- "z": "00011000",
- "A": "00011001",
- "B": "00011010",
- "C": "00011011",
- "D": "00011100",
- "E": "00011101",
- "F": "00011110",
- "G": "00011111",
- "H": "00100000",
- "I": "00100001",
- "J": "00100010",
- "K": "00100011",
- "L": "00100100",
- "M": "00100101",
- "N": "00100110",
- "O": "00100111",
- "P": "00101000",
- "Q": "00101001",
- "R": "00101010",
- "S": "00101011",
- "T": "00101100",
- "U": "00101101",
- "V": "00101110",
- "W": "00101111",
- "X": "100010011",
- "Y": "00110000",
- "Z": "00110001",
- "1": "00110010",
- "2": "00110011",
- "3": "00110100",
- "4": "00110101",
- "5": "00110110",
- "6": "00110111",
- "7": "00111000",
- "8": "00111001",
- "9": "00111010",
- "0": "00111011",
- " ": "10000100" }
- print("Please wait until all resources are loaded... ")
- def root():
- answer = input("Decode or encode? >>> ")
- if answer.lower() == "decode":
- print(text_decode)
- encode_s = input(" >> ")
- print(' '.join(list(numbers.keys())[list(numbers.values()).index(c)] for c in encode_s.split()))
- root()
- elif answer.lower() == "encode":
- print(text_encode)
- decode_s = input(" >> ")
- print(' '.join(numbers[c] for c in decode_s))
- root()
- root()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement