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
JellieJayde 271767d4e3 Jayde Test
2024-04-11 12:27:23 -04:00

44 lines
1.5 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
# ----------------------------------------------------------qwerty
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
if c != " ":
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
else:
dataDecrypted = dataDecrypted + c
return dataDecrypted
with open("dataEncoded.txt", "r") as f:
data = "".join(c for c in f.readlines() if c != "\n")
print(decrypt(data, "qwertyuiopasdfghjklzxcvbnm"))