This repository has been archived on 2025-05-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
CutieDecryptor/CutieDecrypt.py
2024-04-11 11:39:33 -04:00

40 lines
1.3 KiB
Python

#!~/.pyenv/versions/3.11.6/bin/python
#
# Copyright (c) 2024 Cutieguwu | Olivia Brooks
#
# -*- coding:utf-8 -*-
# @Title: CutieDecryptor
# @Author: Cutieguwu | Olivia Brooks
# @Collaborator: JellieJayde | Jayde Paquette
# @Email: owen.brooks77@gmail.com | obroo2@ocdsb.ca
# @Description: Decrypts a file.
#
# @Script: CutieDecrypt.py
# @Date Created: 10 Apr, 2024
# @Last Modified: 11 Apr, 2024
# @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"))