""" Author: unknown Consulted: Date: 2022-3-27 Purpose: A mysterious program. If the correct password is put into the correct file, it will decode a hidden message. But if the wrong password is given, the message will be deleted. """ # Import our secret functions from secrets import * # Variables for file names ENCRYPTED = "encrypted.txt" DECRYPTED = "message.txt" def passwordFilename(): "Computes the password filename." return a(a(a('.py','per'), 'his'), 'w') def decodeFile(): """ Decodes the encrypted file, or deletes it if the password is wrong. """ with open('attempts.txt', 'a') as attemptsOutput: attemptsOutput.write('.') # Read the encrypted message with open(ENCRYPTED, 'r') as encryptedInput: encrypted = encryptedInput.read() # Try to read the password file try: with open(passwordFilename(), 'r') as fileInput: password = fileInput.read() except FileNotFoundError: # If we can't find the file, stop print("No password file found.") return # Check the password, and either decrypt or delete the file if password == b('Very Secret Password'): # Decrypt the message answer = d(encrypted, password) with open(DECRYPTED, 'w') as outputFile: outputFile.write(answer) else: # Erase the message if the password is wrong print("Wrong password! Erasing the message.") with open(ENCRYPTED, 'w') as outputFile: outputFile.write("Message erased.\n") decodeFile()