diff --git a/CutieDecrypt.py b/CutieDecrypt.py index d4f7a98..60196db 100644 --- a/CutieDecrypt.py +++ b/CutieDecrypt.py @@ -15,3 +15,26 @@ # @Last Modified by: Cutieguwu | Olivia Brooks # ---------------------------------------------------------- +def decrypt(dataEncoded: str, keyDecrypt: str): + """ + Decrypts a string encoded using a substitution cypher based on the provided key.\n + Characters closer to index 0 in `key` are more common in the English language. + """ + + dataDecrypted = "" + + keyEnglish = "etaoinshrdlcumwfgypbvkjxqz" # Lewand's order of english characters; most to least common. + + for c in dataEncoded: + is_found = False + + while not is_found: + for k in keyDecrypt: + if c == k: # Character found in decryption key. + dataDecrypted = dataDecrypted + keyEnglish[keyDecrypt.index(k)] + is_found = True + + return dataDecrypted + + +print(decrypt("asdafhedjwandseifhbjnwj", "qwertyuiopasdfghjklzxcvbnm")) \ No newline at end of file