Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add in_decrypt_str argument to _run_puzzle #29

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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