From 2408ba8e975ae5d5c5ffcbfc759d8fae0d7b21ab Mon Sep 17 00:00:00 2001 From: vil02 <65706193+vil02@users.noreply.github.com> Date: Wed, 24 Jul 2024 17:37:29 +0200 Subject: [PATCH] refactor: add `in_decrypt_str` argument to `_run_puzzle` --- puzzle_generator/create_puzzle.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/puzzle_generator/create_puzzle.py b/puzzle_generator/create_puzzle.py index 6ed7692..734dbc7 100644 --- a/puzzle_generator/create_puzzle.py +++ b/puzzle_generator/create_puzzle.py @@ -4,22 +4,21 @@ from .puzzle_data_encryption import decrypt_data, encrypt_data from . import simple_encryption_utils as seu -from .simple_encryption_utils import decrypt_str from . import bytestr_utils as bu -def _run_puzzle(in_puzzle): +def _run_puzzle(in_puzzle, in_decrypt_str): print(in_puzzle["str"]) if "rest" in in_puzzle: this_pass = input() new_puzzle = decrypt_data( - in_puzzle["rest"], in_puzzle["hash"], this_pass, decrypt_str + in_puzzle["rest"], in_puzzle["hash"], this_pass, in_decrypt_str ) if new_puzzle is None: print("This is a wrong answer. Try again!") sys.exit(1) else: - _run_puzzle(new_puzzle) + _run_puzzle(new_puzzle, in_decrypt_str) def _create_str(in_modules, in_functions, in_encrypted_puzzle): @@ -31,7 +30,7 @@ def _create_str(in_modules, in_functions, in_encrypted_puzzle): modules_str = "\n".join("import " + _ for _ in in_modules) + "\n" functions_str = "\n".join(inspect.getsource(_) for _ in in_functions) puzzle_data_str = f"_PUZZLE = {in_encrypted_puzzle}" - call_str = "_run_puzzle(_PUZZLE)" + call_str = "_run_puzzle(_PUZZLE, decrypt_str)" return ( "\n".join( @@ -52,7 +51,7 @@ def create(in_puzzle, output_path: pathlib.Path) -> None: seu.proc_bytes, seu.decrypt_bytes, bu.bytestr_to_bytes, - decrypt_str, + seu.decrypt_str, decrypt_data, _run_puzzle, ]