Published Jul 31st, 2025, 7/31/25 7:27 pm
- 129 views • 4 today
- 11
- 9
221
The other day I made an encoder that takes user-provided text input and converts it into a series of numbers. These numbers are laid out in the following order:
Starts with 0: Space
Starts with 1: A-Z, a-z
Starts with 2: 1-0 (as formulated on a normal keyboard)
Starts with 3: Special characters typeable on a normal keyboard, in order of where they appear, with non-shift characters coming before their shift counterpart.
Later, I used the same format to encode them into a hexadecimal code. This is in the same layout, though the first number does not define the type of character.
Today, I shared a wall post with one of these hexadecimal codes, this translates into a question of if anyone wants the Python code used to generate these hexadecimal codes. After around three hours, one person solved it, this person being MISTERMEGA.
Now, I am obligated to share the code. So, here it is:
(Note: some comments may vary between versions due to some cleaning up I did today. You will need some form of Python interpreter to run the code. If you have one installed on your device, that'll work great. But, if not, you will need to install one, or use an online one. For example, Online GDB.)
I apologize for any bugs in the code, I can assure you, it ran well on my end, though perhaps copy and pasting it, caused the formatting to get messed up. If you find any bugs, let me know, and I shall attempt to fix them.
Starts with 0: Space
Starts with 1: A-Z, a-z
Starts with 2: 1-0 (as formulated on a normal keyboard)
Starts with 3: Special characters typeable on a normal keyboard, in order of where they appear, with non-shift characters coming before their shift counterpart.
Later, I used the same format to encode them into a hexadecimal code. This is in the same layout, though the first number does not define the type of character.
Today, I shared a wall post with one of these hexadecimal codes, this translates into a question of if anyone wants the Python code used to generate these hexadecimal codes. After around three hours, one person solved it, this person being MISTERMEGA.
Now, I am obligated to share the code. So, here it is:
(Note: some comments may vary between versions due to some cleaning up I did today. You will need some form of Python interpreter to run the code. If you have one installed on your device, that'll work great. But, if not, you will need to install one, or use an online one. For example, Online GDB.)
Code without hexadecimal encoding (uses original custom number encoding)
"""
A Python encoder that translates English characters into some numerical codes.
July 29th-30st, 2025
"""
numbers = ["000", "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "211", "122", "123", "124", "125", "126", "127", "128", "129", "130", "131", "132", "133", "134", "135", "136", "137", "138", "139", "140", "141", "142", "143", "144", "145", "146", "147", "148", "149", "150", "151", "200", "201", "202", "203", "204", "205", "206", "207", "208", "209", "300", "301", "302", "303", "304", "305", "306", "307", "308", "309", "310", "311", "312", "313", "314", "315", "316", "317", "318", "319", "320", "321", "322", "323", "324", "325", "326", "327", "328", "329", "330", "331", "332", "333"] # The number versions of the characters below
english = [" ", "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", "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", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "`", "-", "=", "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "\t", "[", "]", "\\", "{", "}", "|", ";", "\'", ":", "\"", "\n", ",", ".", "/", "<", ">", "?"] # The aforementioned characters below
# Here's the function for encoding text
def encode(text):
output = ""
# This iterates through the provided text parameter, and finds the corresponding numerical value of each letter in the text.
for char in text:
try: # This handles what's supposed to happen,
index = english.index(char) # This sets the index variable to the current character
output += numbers[index] # And this takes that index, and adds its corresponding value to the output variable
except ValueError: # And this handles what happens when an unsupported character is entered
print(f"Warning: '{char}' is not a supported character.")
output += " " # This adds ' ' as a placeholder code in place of unsupported characters. It uses three question mark thingies to keep all the codes divisible by three, which makes decoding it a hell of a lot easier.
# This returns the output variable when the function is called
return output
# Here's the function for decoding numerical codes
def decode(text):
output = ""
# Iterates through the code provided, in chunks of three
for i in range(0, len(text), 3): # Steps by 3, as each character in english has a corresponding three-digit value
chunk = text[i:i+3] # Gets three consecutive numbers, each set is equal to a single character in english
try: # This handles what is to happen when valid codes are submitted
index = numbers.index(chunk)
output += english[index]
except ValueError: # This handles what's meant to happen when invalid codes are submitted
print(f"Warning: '{chunk}' is not a supported code.")
output += " " # This is the placeholder for unsupported characters.
return output
# Handles user input
mode = input("Would you like to encode (1), or decode (2)? (1/2)\n") # Asks whether the user would like to encode, or decode, and sets the mode variable accordingly
# The following handles what is done with the entered mode
if mode == "1": # If the mode is set to 1, which is for encoding, then the following will be executed.
encoded = encode(input("Enter the text you'd like to encode: \n")) # Sets the encoded variable to the encoded version of the entered text
print("Encoded text:\n" + encoded) # Prints the encoded variable to the console
elif mode == "2": # If the mode is set to 2, which is for decoding, then the following will be executed.
decoded = decode(input("Enter the text you'd like to decode: \n")) # Sets the decoded variable to the english version of the entered text
print("Decoded text:\n" + decoded) # Prints the decoded variable to the console
else: # If the user enters an invalid mode, the shall be informed with the following script. The program shall then be killed.
print("Invalid mode selected. Please enter '1' to encode or '2' to decode.")
A Python encoder that translates English characters into some numerical codes.
July 29th-30st, 2025
"""
numbers = ["000", "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "211", "122", "123", "124", "125", "126", "127", "128", "129", "130", "131", "132", "133", "134", "135", "136", "137", "138", "139", "140", "141", "142", "143", "144", "145", "146", "147", "148", "149", "150", "151", "200", "201", "202", "203", "204", "205", "206", "207", "208", "209", "300", "301", "302", "303", "304", "305", "306", "307", "308", "309", "310", "311", "312", "313", "314", "315", "316", "317", "318", "319", "320", "321", "322", "323", "324", "325", "326", "327", "328", "329", "330", "331", "332", "333"] # The number versions of the characters below
english = [" ", "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", "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", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "`", "-", "=", "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "\t", "[", "]", "\\", "{", "}", "|", ";", "\'", ":", "\"", "\n", ",", ".", "/", "<", ">", "?"] # The aforementioned characters below
# Here's the function for encoding text
def encode(text):
output = ""
# This iterates through the provided text parameter, and finds the corresponding numerical value of each letter in the text.
for char in text:
try: # This handles what's supposed to happen,
index = english.index(char) # This sets the index variable to the current character
output += numbers[index] # And this takes that index, and adds its corresponding value to the output variable
except ValueError: # And this handles what happens when an unsupported character is entered
print(f"Warning: '{char}' is not a supported character.")
output += " " # This adds ' ' as a placeholder code in place of unsupported characters. It uses three question mark thingies to keep all the codes divisible by three, which makes decoding it a hell of a lot easier.
# This returns the output variable when the function is called
return output
# Here's the function for decoding numerical codes
def decode(text):
output = ""
# Iterates through the code provided, in chunks of three
for i in range(0, len(text), 3): # Steps by 3, as each character in english has a corresponding three-digit value
chunk = text[i:i+3] # Gets three consecutive numbers, each set is equal to a single character in english
try: # This handles what is to happen when valid codes are submitted
index = numbers.index(chunk)
output += english[index]
except ValueError: # This handles what's meant to happen when invalid codes are submitted
print(f"Warning: '{chunk}' is not a supported code.")
output += " " # This is the placeholder for unsupported characters.
return output
# Handles user input
mode = input("Would you like to encode (1), or decode (2)? (1/2)\n") # Asks whether the user would like to encode, or decode, and sets the mode variable accordingly
# The following handles what is done with the entered mode
if mode == "1": # If the mode is set to 1, which is for encoding, then the following will be executed.
encoded = encode(input("Enter the text you'd like to encode: \n")) # Sets the encoded variable to the encoded version of the entered text
print("Encoded text:\n" + encoded) # Prints the encoded variable to the console
elif mode == "2": # If the mode is set to 2, which is for decoding, then the following will be executed.
decoded = decode(input("Enter the text you'd like to decode: \n")) # Sets the decoded variable to the english version of the entered text
print("Decoded text:\n" + decoded) # Prints the decoded variable to the console
else: # If the user enters an invalid mode, the shall be informed with the following script. The program shall then be killed.
print("Invalid mode selected. Please enter '1' to encode or '2' to decode.")
Code with hexadecimal encoding
"""
This is a Python encoder that translates English characters into hexadecimal codes.
July 29th-31st, 2025
"""
hexadecimal = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60"] # The hexadecimal code versions of the english list
english = [" ", "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", "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", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "`", "-", "=", "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "\t", "[", "]", "\\", "{", "}", "|", ";", "\'", ":", "\"", "\n", ",", ".", "/", "<", ">", "?"] # The english list.
# Here's the function for encoding text
def encode(text):
output = ""
# This iterates through the provided text parameter, and finds the corresponding numerical value of each letter in the text.
for char in text:
try: # This handles what's supposed to happen,
index = english.index(char) # This sets the index variable to the current character
output += hexadecimal[index] # And this takes that index, and adds its corresponding value to the output variable
except ValueError: # And this handles what happens when an unsupported character is entered
print(f"Warning: '{char}' is not a supported character.")
output += "��" # This adds '��' as a placeholder code in place of unsupported characters. It uses towquestion mark thingies to keep all the codes divisible by two, which makes decoding it a hell of a lot easier.
# This returns the output variable when the function is called
return output
# Here's the function for decoding numerical codes
def decode(text):
output = ""
# Iterates through the code provided, in chunks of two
for i in range(0, len(text), 2): # Steps by 2, as each character in english has a corresponding two-digit value
chunk = text[i:i+2] # Gets two consecutive characters, each set is equal to a single character in english
try: # This handles what is to happen when valid codes are submitted
index = hexadecimal.index(chunk)
output += english[index]
except ValueError: # This handles what's meant to happen when invalid codes are submitted
print(f"Warning: '{chunk}' is not a supported code.")
output += "�" # This is the placeholder for unsupported characters.
return output
# Handles user input
mode = input("Would you like to encode (1), or decode (2)? (1/2)\n") # Asks whether the user would like to encode, or decode, and sets the mode variable accordingly
# The following handles what is done with the entered mode
if mode == "1": # If the mode is set to 1, which is for encoding, then the following will be executed.
encoded = encode(input("Enter the text you'd like to encode: \n")) # Sets the encoded variable to the encoded version of the entered text
print("Encoded text:\n" + encoded) # Prints the encoded variable to the console
elif mode == "2": # If the mode is set to 2, which is for decoding, then the following will be executed.
decoded = decode(input("Enter the text you'd like to decode: \n")) # Sets the decoded variable to the english version of the entered text
print("Decoded text:\n" + decoded) # Prints the decoded variable to the console
else: # If the user enters an invalid mode, the shall be informed with the following script. The program shall then be killed.
print("Invalid mode selected. Please enter '1' to encode or '2' to decode.")
This is a Python encoder that translates English characters into hexadecimal codes.
July 29th-31st, 2025
"""
hexadecimal = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60"] # The hexadecimal code versions of the english list
english = [" ", "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", "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", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "`", "-", "=", "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "\t", "[", "]", "\\", "{", "}", "|", ";", "\'", ":", "\"", "\n", ",", ".", "/", "<", ">", "?"] # The english list.
# Here's the function for encoding text
def encode(text):
output = ""
# This iterates through the provided text parameter, and finds the corresponding numerical value of each letter in the text.
for char in text:
try: # This handles what's supposed to happen,
index = english.index(char) # This sets the index variable to the current character
output += hexadecimal[index] # And this takes that index, and adds its corresponding value to the output variable
except ValueError: # And this handles what happens when an unsupported character is entered
print(f"Warning: '{char}' is not a supported character.")
output += "��" # This adds '��' as a placeholder code in place of unsupported characters. It uses towquestion mark thingies to keep all the codes divisible by two, which makes decoding it a hell of a lot easier.
# This returns the output variable when the function is called
return output
# Here's the function for decoding numerical codes
def decode(text):
output = ""
# Iterates through the code provided, in chunks of two
for i in range(0, len(text), 2): # Steps by 2, as each character in english has a corresponding two-digit value
chunk = text[i:i+2] # Gets two consecutive characters, each set is equal to a single character in english
try: # This handles what is to happen when valid codes are submitted
index = hexadecimal.index(chunk)
output += english[index]
except ValueError: # This handles what's meant to happen when invalid codes are submitted
print(f"Warning: '{chunk}' is not a supported code.")
output += "�" # This is the placeholder for unsupported characters.
return output
# Handles user input
mode = input("Would you like to encode (1), or decode (2)? (1/2)\n") # Asks whether the user would like to encode, or decode, and sets the mode variable accordingly
# The following handles what is done with the entered mode
if mode == "1": # If the mode is set to 1, which is for encoding, then the following will be executed.
encoded = encode(input("Enter the text you'd like to encode: \n")) # Sets the encoded variable to the encoded version of the entered text
print("Encoded text:\n" + encoded) # Prints the encoded variable to the console
elif mode == "2": # If the mode is set to 2, which is for decoding, then the following will be executed.
decoded = decode(input("Enter the text you'd like to decode: \n")) # Sets the decoded variable to the english version of the entered text
print("Decoded text:\n" + decoded) # Prints the decoded variable to the console
else: # If the user enters an invalid mode, the shall be informed with the following script. The program shall then be killed.
print("Invalid mode selected. Please enter '1' to encode or '2' to decode.")
I apologize for any bugs in the code, I can assure you, it ran well on my end, though perhaps copy and pasting it, caused the formatting to get messed up. If you find any bugs, let me know, and I shall attempt to fix them.
| Tags |
6690618
6

Have something to say?