import hashlib
def mystery(x):
"""
mystery(x) -> bool
Returns True precisely for the single (string) input whose SHA-256
hash matches a fixed target digest embedded below. For any non-string
input the function returns False.
"""
target = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
if isinstance(x, str):
h = hashlib.sha256(x.encode("utf-8")).hexdigest()
return h == target
return False
import hmac
import math
def mystery(x):
# Normalize input to bytes
if isinstance(x, bool):
return False
if isinstance(x, int):
if x < 0:
return False
b = str(x).encode("ascii")
elif isinstance(x, float):
if not (math.isfinite(x) and x.is_integer()):
return False
b = str(int(x)).encode("ascii")
elif isinstance(x, str):
try:
b = x.encode("utf-8")
except Exception:
return False
else:
return False
# Quick structural checks (red herrings unless you're close)
if len(b) != 21:
return False
if (sum((i + 1) * bb for i, bb in enumerate(b)) % 997) != 963:
return False
xacc = 0
for bb in b:
xacc ^= bb
if xacc != 0x62:
return False
# Recover the reference encrypted bytes (obfuscated storage)
stored = bytes.fromhex("6248958e34f6b0510fc9a337babb550edc9a75ffa2")
ref = bytes((bb ^ 0x5A) for bb in stored)[::-1]
# Encrypt candidate with a position-dependent mask and compare
out = bytearray(21)
for i, bb in enumerate(b):
m = (((i * 73 + 41) & 0xFF) ^ 0xA5)
out[i] = bb ^ m
return hmac.compare_digest(bytes(out), ref)
import hmac
def mystery(x):
"""
mystery(x) -> bool
A deliberately obfuscated string check. Accepts only str inputs;
performs a few quick numeric consistency checks on the UTF-8 bytes
and then applies a position-dependent mask. The reference bytes are
stored in an obfuscated form (hex); the function reconstructs them
and compares using a timing-safe comparison.
Only a single (string) input will cause this to return True.
"""
if not isinstance(x, str):
return False
try:
b = x.encode("utf-8")
except Exception:
return False
# Structural checks (reduce search space)
if len(b) != 13:
return False
if (sum((i + 1) * bb for i, bb in enumerate(b)) % 997) != 925:
return False
xacc = 0
for bb in b:
xacc ^= bb
if xacc != 0x64:
return False
# Obfuscated storage of the reference bytes (hex)
stored = bytes.fromhex("55de5bce478860a470fb7cfe80")
# Deobfuscate to recover the expected masked output
ref = bytes((bb ^ 0x5A) for bb in stored)[::-1]
# Apply the same position-dependent mask to the candidate
out = bytearray(len(b))
for i, bb in enumerate(b):
m = (((i * 123) & 0xFF) ^ 0xAA)
out[i] = bb ^ m
return hmac.compare_digest(bytes(out), ref)
import hmac
import math
def _rotl8(v, r):
r &= 7
return ((v << r) | (v >> (8 - r))) & 0xFF
def _mask(i):
# Fixed, position-dependent mask (intentionally non-obvious but deterministic)
a = (i * 73 + 19) & 0xFF
b = (i * i * 11) & 0xFF
return (a ^ b ^ 0xA6) & 0xFF
def _kstream(n):
# Tiny fixed PRNG used only to obfuscate the embedded reference bytes
s = 0xA5
for i in range(n):
s = (s * 37 + 23) & 0xFF
yield (s ^ ((i * 19) & 0xFF) ^ 0x5A) & 0xFF
def mystery(x):
# Normalize x -> bytes
if isinstance(x, bool):
return False
if isinstance(x, int):
b = str(x).encode("ascii")
elif isinstance(x, float):
if not (math.isfinite(x) and x.is_integer()):
return False
b = str(int(x)).encode("ascii")
elif isinstance(x, str):
try:
b = x.encode("utf-8")
except Exception:
return False
else:
return False
# Structural checks (to frustrate naive brute force)
if len(b) != 17:
return False
if any((bb < 32 or bb > 126) for bb in b): # require printable ASCII
return False
if (sum(b) % 251) != 3:
return False
xacc = 0
for bb in b:
xacc ^= bb
if xacc != 0x42:
return False
if (sum((i + 1) * bb for i, bb in enumerate(b)) % 997) != 100:
return False
# Reconstruct expected transformed bytes from an obfuscated embedded blob
stored = bytes.fromhex("6cae041c5b886a9778db0d57155388de13") # 17 bytes
n = 17
ks = list(_kstream(n))
def p(i): # permutation
return (i * 7 + 3) % n
ref = bytes(stored[p(i)] ^ ks[i] for i in range(n))
# Transform candidate bytes and compare
out = bytearray(n)
for i, bb in enumerate(b):
t = bb ^ _mask(i)
r = (i * 5 + 3) % 8
out[i] = _rotl8(t, r)
return hmac.compare_digest(bytes(out), ref)
import hmac
def mystery(x):
"""
mystery(x) -> bool
A deliberately obfuscated string check. Accepts only str inputs;
performs several quick structural checks on the UTF-8 bytes and then
applies a simple position-dependent mask. The expected transformed
bytes are embedded in an obfuscated form (hex).
"""
if not isinstance(x, str):
return False
try:
b = x.encode("utf-8")
except Exception:
return False
# Structural checks to reduce brute-force space
if len(b) != 15:
return False
if any(bb < 32 or bb > 126 for bb in b): # printable ASCII only
return False
if (sum(b) % 257) != 199:
return False
xacc = 0
for bb in b:
xacc ^= bb
if xacc != 13:
return False
if (sum((i + 1) * bb for i, bb in enumerate(b)) % 997) != 962:
return False
# Obfuscated storage of the reference transformed bytes (hex)
stored = bytes.fromhex("6895b29a4972003d91b0944a610d1f")
# Deobfuscate to recover the expected transformed bytes
ref = bytes((bb ^ 0x5A) for bb in stored)[::-1]
# Apply the same position-dependent mask to the candidate
out = bytearray(len(b))
for i, bb in enumerate(b):
m = ((i * 37 + 13) & 0xFF)
out[i] = bb ^ m
return hmac.compare_digest(bytes(out), ref)
import hashlib
import hmac
import math
def _rotl8(v, r):
r &= 7
return ((v << r) | (v >> (8 - r))) & 0xFF
def _derive_key():
# Deterministic "key schedule" (more noise than security)
seed = hashlib.sha256(b"misdirection::feistel").digest()
k = bytearray(32)
for i, bb in enumerate(seed):
k[i] = _rotl8(bb ^ ((i * 29 + 113) & 0xFF), i)
return bytes(k)
def _feistel_encrypt(block24, key32, rounds=8):
if len(block24) != 24:
raise ValueError("block must be 24 bytes")
L = block24[:12]
R = block24[12:]
k = key32
for r in range(rounds):
# round function: SHA-256 keyed, take first 12 bytes
F = hashlib.sha256(k + bytes([r]) + R + bytes([r ^ 0xA5])).digest()[:12]
L, R = R, bytes((l ^ f) for l, f in zip(L, F))
# tiny evolving subkey (keeps things annoying to read, still deterministic)
k = hashlib.sha256(k + bytes([r]) + F).digest()
return L + R
def _reveal_plaintext():
# Stored 24 bytes (obfuscated), then unpermuted & unmixed to get the real plaintext
stored = bytes.fromhex(
"778e67deafba5af09db7c5f489d454b495605ca4e8726194"
)
def mask1(i):
return (i * 37 + 13) & 0xFF
def mask2(j):
return (j * 29 + 101) & 0xFF
n = 24
# permutation p(j) = (7*j + 3) mod 24
def p(j):
return (j * 7 + 3) % n
# Recover e[i] such that: stored[j] = e[p(j)] XOR mask2(j)
e = [0] * n
for j, sb in enumerate(stored):
e[p(j)] = sb ^ mask2(j)
# Recover plaintext bytes: pt[i] = e[i] XOR mask1(i)
pt = bytes((e[i] ^ mask1(i)) & 0xFF for i in range(n))
return pt
def mystery(x):
# Normalize x -> bytes
if isinstance(x, bool):
return False
if isinstance(x, int):
b = str(x).encode("ascii")
elif isinstance(x, float):
if not (math.isfinite(x) and x.is_integer()):
return False
b = str(int(x)).encode("ascii")
elif isinstance(x, str):
try:
b = x.encode("utf-8")
except Exception:
return False
else:
return False
# Structural constraints (annoying but deterministic)
if len(b) != 24:
return False
if any((bb < 32 or bb > 126) for bb in b): # printable ASCII only
return False
if (sum(b) % 97) != 8:
return False
xacc = 0
for bb in b:
xacc ^= bb
if xacc != 59:
return False
if (sum((i + 1) * bb for i, bb in enumerate(b)) % 251) != 9:
return False
# Encrypt candidate and compare against encrypted hidden reference plaintext
key = _derive_key()
ref_plain = _reveal_plaintext()
ref_ct = _feistel_encrypt(ref_plain, key, rounds=8)
cand_ct = _feistel_encrypt(b, key, rounds=8)
return hmac.compare_digest(cand_ct, ref_ct)
import hmac
def mystery(x):
"""
mystery(x) -> bool
A compact but obfuscated string-only check. The function only accepts
str inputs and applies several quick structural filters (length,
printable ASCII, modular sums, XOR accumulator, weighted-sum mod)
to frustrate naive brute-force. If those pass, the candidate's bytes
are masked with a simple position-dependent mask and compared (via
a timing-safe compare) to an embedded, obfuscated reference blob.
Only a single printable ASCII string will make this return True.
"""
if not isinstance(x, str):
return False
try:
b = x.encode("utf-8")
except Exception:
return False
# Structural filters
if len(b) != 12:
return False
if any(bb < 32 or bb > 126 for bb in b): # printable ASCII only
return False
if (sum(b) % 257) != 157:
return False
xacc = 0
for bb in b:
xacc ^= bb
if xacc != 5:
return False
if (sum((i + 1) * bb for i, bb in enumerate(b)) % 997) != 136:
return False
# Obfuscated storage of the reference transformed bytes (hex)
stored = bytes.fromhex("1d2a173fcaeb83a750670b23")
# Deobfuscate to recover the expected transformed bytes
ref = bytes((bb ^ 0x5A) for bb in stored)[::-1]
# Apply the same simple position-dependent mask to the candidate
out = bytearray(len(b))
for i, bb in enumerate(b):
m = (i * 31 + 17) & 0xFF
out[i] = bb ^ m
return hmac.compare_digest(bytes(out), ref)
import hashlib
import hmac
import math
def _rotl8(v, r):
r &= 7
return ((v << r) | (v >> (8 - r))) & 0xFF
def _rotl32(v, r):
r &= 31
return ((v << r) | (v >> (32 - r))) & 0xFFFFFFFF
def _derive_key(code_bytes: bytes) -> bytes:
# Key derived from the function's own bytecode (deterministic, but annoying).
return hashlib.blake2s(code_bytes + b"::mystery::v2", digest_size=32).digest()
def _prng32(seed16: bytes):
# xoshiro-ish 32-bit PRNG (deterministic)
s0, s1, s2, s3 = [int.from_bytes(seed16[i:i+4], "little") for i in range(0, 16, 4)]
while True:
res = (s0 + s3) & 0xFFFFFFFF
t = (s1 << 9) & 0xFFFFFFFF
s2 ^= s0
s3 ^= s1
s1 ^= s2
s0 ^= s3
s2 ^= t
s3 = _rotl32(s3, 11)
yield res
def _sbox(key32: bytes) -> bytes:
# Build a keyed permutation of 0..255 via Fisher-Yates.
seed = hashlib.sha256(key32 + b"::sbox").digest()[:16]
g = _prng32(seed)
box = list(range(256))
for i in range(255, 0, -1):
j = next(g) % (i + 1)
box[i], box[j] = box[j], box[i]
return bytes(box)
def _keystream(key32: bytes, n: int) -> bytes:
seed = hashlib.blake2s(key32 + b"::ks", digest_size=16).digest()
g = _prng32(seed)
out = bytearray()
while len(out) < n:
out.extend(next(g).to_bytes(4, "little"))
return bytes(out[:n])
def _enc(msg: bytes, key32: bytes) -> bytes:
box = _sbox(key32)
ks = _keystream(key32, len(msg))
out = bytearray(len(msg))
for i, bb in enumerate(msg):
v = bb ^ ks[i]
v = box[v]
v ^= (i * 31 + 0xA7) & 0xFF
v = _rotl8(v, (i * 5 + (ks[i] & 7)) & 7)
out[i] = v
return bytes(out)
def _reveal_plaintext() -> bytes:
# 23 bytes, stored permuted and masked.
stored = bytes.fromhex("340c0ae0c7ede28b868269744852142d3e11e4dac9a3a1")
n = 23
def p(j):
return (7 * j + 3) % n
def mask(j):
return (17 * j + 93) & 0xFF
pt = [0] * n
for j, sb in enumerate(stored):
pt[p(j)] = sb ^ mask(j)
return bytes(pt)
def mystery(x):
# Normalize x -> bytes
if isinstance(x, bool):
return False
if isinstance(x, int):
b = str(x).encode("ascii")
elif isinstance(x, float):
if not (math.isfinite(x) and x.is_integer()):
return False
b = str(int(x)).encode("ascii")
elif isinstance(x, str):
try:
b = x.encode("utf-8")
except Exception:
return False
else:
return False
# Structural constraints (fixed)
if len(b) != 23:
return False
if any(bb < 32 or bb > 126 for bb in b): # printable ASCII
return False
if (sum(b) % 251) != 94:
return False
xacc = 0
for bb in b:
xacc ^= bb
if xacc != 0x3D:
return False
if (sum((i + 1) * bb for i, bb in enumerate(b)) % 997) != 986:
return False
# Keyed transform check against hidden plaintext (obfuscated storage)
key = _derive_key(mystery.__code__.co_code)
ref_plain = _reveal_plaintext()
return hmac.compare_digest(_enc(b, key), _enc(ref_plain, key))
import hmac
def mystery(x):
"""
mystery(x) -> bool
Hard-to-inspect puzzle: accepts only a single printable-ASCII string
of length 16 which passes several arithmetic/XOR filters and then a
non-trivial position-dependent transform. The expected transformed
bytes are stored in an obfuscated hex blob below.
"""
if not isinstance(x, str):
return False
try:
b = x.encode("utf-8")
except Exception:
return False
# Structural filters (reduce brute-force space)
if len(b) != 16:
return False
if any(bb < 32 or bb > 126 for bb in b):
return False
if (sum(b) % 257) != 41:
return False
xacc = 0
for bb in b:
xacc ^= bb
if xacc != 15:
return False
if (sum((i + 1) * bb for i, bb in enumerate(b)) % 997) != 728:
return False
# Obfuscated storage of the expected transformed bytes
stored = bytes.fromhex("59ab7a16ca8b619ba55406d08d28e3b5")
# Deobfuscate: reverse then XOR with 0x5A to recover reference
ref = bytes((bb ^ 0x5A) for bb in stored)[::-1]
# Apply the same position-dependent transform to candidate
out = bytearray(len(b))
for i, bb in enumerate(b):
m = (((i * 73 + 41) & 0xFF) ^ 0xA5)
out[i] = ((bb ^ m) + i) & 0xFF
return hmac.compare_digest(bytes(out), ref)
import hashlib
import hmac
import math
def _rotl8(v, r):
r &= 7
return ((v << r) | (v >> (8 - r))) & 0xFF
def _derive_key(code_bytes: bytes) -> bytes:
# Deterministic per-function key derived from bytecode (annoying but stable per runtime).
return hashlib.blake2s(code_bytes + b"::mystery::key::v3", digest_size=32).digest()
def _xorshift32(seed: int):
x = seed & 0xFFFFFFFF
while True:
x ^= (x << 13) & 0xFFFFFFFF
x ^= (x >> 17) & 0xFFFFFFFF
x ^= (x << 5) & 0xFFFFFFFF
yield x
def _sbox(key32: bytes) -> bytes:
# Keyed Fisher–Yates shuffle -> permutation of 0..255
seed = int.from_bytes(hashlib.sha256(key32 + b"::sbox").digest()[:4], "little")
g = _xorshift32(seed)
box = list(range(256))
for i in range(255, 0, -1):
j = next(g) % (i + 1)
box[i], box[j] = box[j], box[i]
return bytes(box)
def _keystream(key32: bytes, n: int) -> bytes:
out = bytearray()
ctr = 0
while len(out) < n:
out.extend(hashlib.sha256(key32 + b"::ks::" + ctr.to_bytes(4, "little")).digest())
ctr += 1
return bytes(out[:n])
def _enc(msg: bytes, key32: bytes) -> bytes:
box = _sbox(key32)
ks = _keystream(key32, len(msg))
out = bytearray(len(msg))
for i, bb in enumerate(msg):
v = bb ^ ks[i]
v = box[v]
v ^= ((i * 29 + 113) & 0xFF)
v = _rotl8(v, (ks[i] ^ i) & 7)
out[i] = v
return bytes(out)
def _reveal_plaintext() -> bytes:
# The true plaintext is hidden via a permutation and per-position mask.
stored = bytes.fromhex("d0981d5f496a82db5a1558cdc841b261644a4d293f75")
n = 22
def p(j):
return (7 * j + 3) % n
def mask(j):
return (((j * 73 + 19) & 0xFF) ^ ((j * j * 11) & 0xFF) ^ 0xA6) & 0xFF
pt = [0] * n
for j, sb in enumerate(stored):
pt[p(j)] = sb ^ mask(j)
return bytes(pt)
def mystery(x):
# Normalize x -> bytes
if isinstance(x, bool):
return False
if isinstance(x, int):
b = str(x).encode("ascii")
elif isinstance(x, float):
if not (math.isfinite(x) and x.is_integer()):
return False
b = str(int(x)).encode("ascii")
elif isinstance(x, str):
try:
b = x.encode("utf-8")
except Exception:
return False
else:
return False
# Structural constraints (fixed)
if len(b) != 22:
return False
if any(bb < 32 or bb > 126 for bb in b): # printable ASCII only
return False
if (sum(b) % 251) != 18:
return False
xacc = 0
for bb in b:
xacc ^= bb
if xacc != 0x54:
return False
if (sum((i + 1) * bb for i, bb in enumerate(b)) % 997) != 787:
return False
# Extra rolling-hash constraint (still deterministic, just another hurdle)
h = 0
for bb in b:
h = (h * 131 + bb) % 65521
if h != 31969:
return False
# Keyed transform check against hidden plaintext (itself obfuscated above)
key = _derive_key(mystery.__code__.co_code)
ref_plain = _reveal_plaintext()
return hmac.compare_digest(_enc(b, key), _enc(ref_plain, key))