Skip to content

Commit

Permalink
refactor: add in_decrypt_str argument to _run_puzzle
Browse files Browse the repository at this point in the history
  • Loading branch information
vil02 committed Jul 24, 2024
1 parent 7411aba commit 2408ba8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions puzzle_generator/create_puzzle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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(
Expand All @@ -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,
]
Expand Down

0 comments on commit 2408ba8

Please sign in to comment.