Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 1.09 KB

238.md

File metadata and controls

33 lines (27 loc) · 1.09 KB

Python script:

# Mapping defined by pure observation, intuition, manual substitution and repeated runs of code
REVERSE_CIPHER_ALPHABET = {
    'M': 'T', 'I': 'H', 'T': 'E', 'L': 'S', 'O': 'I', 'F': 'N', 'S':'L', 'B':'Y', 'K': 'R', 'W': 'U', 'Z': 'B', 'R':'D', 'E':'C', 'D': 'M', 'X': 'V', 'G':'O', 'C': 'W', 'U':'G', 'Q':'K','Y':'F', 'H':'P'
}

def decode_substitution_cipher(cipher_text):
    decoded_message = ''.join(
        REVERSE_CIPHER_ALPHABET.get(char, char) for char in cipher_text.upper()
    )
    return decoded_message

def read_cipher_text(file_path):
    try:
        with open(file_path, 'r', encoding='utf-8') as file:
            return file.read()
    except FileNotFoundError:
        print(f"Error: File '{file_path}' not found.")
        return ""

if __name__ == "__main__":
    file_path = "Substitution.txt"
    cipher_text = read_cipher_text(file_path)
    
    if cipher_text:
        decoded_message = decode_substitution_cipher(cipher_text)
        print("Decoded Message:")
        print(decoded_message)