Skip to content

Instantly share code, notes, and snippets.

@Lubba-64
Created March 21, 2022 14:17
Show Gist options
  • Save Lubba-64/cb726445a3cf26aa0537ba35deee7b6c to your computer and use it in GitHub Desktop.
Save Lubba-64/cb726445a3cf26aa0537ba35deee7b6c to your computer and use it in GitHub Desktop.
import ast
import random
import string
Ascii = ['q','w','r','t','y','p','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m','a','e','i','o','u']
AppIsRunning = True
encodeSTR = """
type ascii for standard english alphabet code, type a list \n
(separated by commas like this: a,b,c,d,e,f,g e.t.c.) for a key containing custom characters \n:"""
print("standard re-map code generator. randomly re-maps characters and encodes sequences with a key.\n")
while AppIsRunning:
inp = input("\n options: decode, keygen, encode, exit.\n:").lower()
if inp == "keygen":
encode = input(encodeSTR).lower()
keydict = {}
if encode == "ascii":
for char in Ascii:
worked = False
while not worked:
testchar = string.printable[random.randint(0,94)]
if (testchar == " "):
continue
if testchar in keydict.values():
continue
keydict[char] = testchar
worked = True
print(f'copy every character after the semicolon to a notepad for decoding:\n{keydict}')
if inp == "decode":
key = input("Input the key you were given to decode with\n:")
key = ast.literal_eval(key)
key = {v: k for k, v in key.items()}
code = input("the string you need to decode\n:")
output = ""
for char in code:
if char in key:
output += key[char]
else:
output += char
print(output)
if inp == "encode":
key = input("Input the key you were given to encode with\n:")
key = ast.literal_eval(key)
toencode = input("input the string you want to encode\n:")
output = ""
for char in toencode:
if char in key:
output += key[char]
else:
output += char
print(f'encoded:{output}')
if inp == "exit":
AppIsRunning = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment