From fb1f5971051da39130caea866699f41815ff35ef Mon Sep 17 00:00:00 2001 From: Cutieguwu Date: Thu, 11 Apr 2024 11:36:00 -0400 Subject: [PATCH] Basic start of decryption. Awaiting parser for further development. --- CutieDecrypt.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CutieDecrypt.py b/CutieDecrypt.py index d4f7a98..29bb23a 100644 --- a/CutieDecrypt.py +++ b/CutieDecrypt.py @@ -15,3 +15,26 @@ # @Last Modified by: Cutieguwu | Olivia Brooks # ---------------------------------------------------------- +def decrypt(dataEncoded: str, key: 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 = "" + + # Convert key to a list. + keyDecrypt = [].append(k for k in key) + keyEnglish = [].append(k for k in "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 +