def mystery(x):
import hashlib, hmac
# Accept either a string or a (Python) integer.
if isinstance(x, str):
b = x.encode("utf-8", "strict")
elif isinstance(x, int):
b = str(x).encode("ascii", "strict")
else:
return False
# Quick reject: exact byte length required.
if len(b) != 16:
return False
def _ror8(v, r):
r &= 7
return v if r == 0 else (((v >> r) | (v << (8 - r))) & 0xFF)
# Reconstruct the hidden 16-byte secret (as bytes) via a reversible per-byte transform.
enc = (
0x7E, 0xC5, 0xD8, 0x43,
0xE8, 0x5C, 0x57, 0x0B,
0xF4, 0x20, 0x10, 0x7F,
0x28, 0x0E, 0x47, 0x5E
)
secret = bytearray(16)
for i, t in enumerate(enc):
r = (i * 3 + 1) & 7
a = (i * 17 + 23) & 0xFF
xmask = (0xA5 ^ ((i * 11) & 0xFF)) & 0xFF
v = t ^ xmask
v = (v - a) & 0xFF
v = _ror8(v, r)
secret[i] = v
secret = bytes(secret)
# Derive a per-input key (so you can't just precompute one fixed digest target).
salt = bytes((((i * 73 + 41) ^ (i >> 1) ^ 0xA6) & 0xFF) for i in range(32))
key = hashlib.sha256(salt + b"mystery" + b[::-1]).digest()[:16]
# Compare keyed hashes (constant-time).
got = hashlib.blake2s(b, key=key, digest_size=32).digest()
want = hashlib.blake2s(secret, key=key, digest_size=32).digest()
return hmac.compare_digest(got, want)
def mystery(x):
import hashlib, hmac
# Accept either a string or a (Python) integer.
if isinstance(x, str):
b = x.encode("utf-8", "strict")
elif isinstance(x, int):
b = str(x).encode("ascii", "strict")
else:
return False
# Quick reject: exact byte length required.
if len(b) != 16:
return False
def _ror8(v, r):
r &= 7
return v if r == 0 else (((v >> r) | (v << (8 - r))) & 0xFF)
# Reconstruct the hidden 16-byte secret (as bytes) via a reversible per-byte transform.
enc = (
229, 250, 25, 174,
212, 226, 77, 51,
66, 138, 41, 226,
127, 4, 249, 3
)
secret = bytearray(16)
for i, t in enumerate(enc):
r = (i * 5 + 3) & 7
a = (i * 13 + 37) & 0xFF
xmask = (0x5A ^ (i * 7 & 0xFF)) & 0xFF
v = t ^ xmask
v = (v - a) & 0xFF
v = _ror8(v, r)
secret[i] = v
secret = bytes(secret)
# Derive a per-input key (so you can't just precompute one fixed digest target).
salt = bytes((((i * 67 + 29) ^ (i >> 2) ^ 0x3D) & 0xFF) for i in range(32))
key = hashlib.sha256(salt + b"mystery" + b[::-1]).digest()[:16]
# Compare keyed hashes (constant-time).
got = hashlib.blake2s(b, key=key, digest_size=32).digest()
want = hashlib.blake2s(secret, key=key, digest_size=32).digest()
return hmac.compare_digest(got, want)
def mystery(x):
import hashlib, hmac
# Accept either a string or a (Python) integer.
if isinstance(x, str):
b = x.encode("utf-8", "strict")
elif isinstance(x, int):
# Integers are converted via their base-10 textual form.
b = str(x).encode("ascii", "strict")
else:
return False
# Fixed-length gate.
if len(b) != 24:
return False
def _ror8(v, r):
r &= 7
return ((v >> r) | ((v << (8 - r)) & 0xFF)) & 0xFF
# Reconstruct a hidden 24-byte secret via a reversible stream-ish transform.
enc = (
65, 120, 115, 54, 145, 113, 18, 62,
173, 192, 83, 75, 116, 125, 10, 199,
65, 136, 181, 95, 74, 54, 240, 222
)
s = 0xC3
prev = 0x5A
secret = bytearray()
for i, e in enumerate(enc):
s = (s * 5 + 17 + i) & 0xFF
w = e ^ prev
u = (w - (13 * i)) & 0xFF
r = (i % 7) + 1
t = _ror8(u, r) # inverse of the encoder's rotate-left
secret.append(t ^ s)
prev = e
secret = bytes(secret)
# Per-input key schedule (depends on the candidate itself).
salt = hashlib.sha256(b"::".join([
bytes(enc),
bytes(((i * 29 + 7) ^ (enc[i % 24] + i)) & 0xFF for i in range(64)),
secret[:8][::-1],
])).digest()
iters = 20000 + (sum(b) & 1023)
key = hashlib.pbkdf2_hmac("sha256", b[::-1] + bytes([len(b)]), salt, iters, dklen=32)
# If b == secret then these match; otherwise you need to solve a nasty fixed-point-ish condition.
got = hmac.new(key, b, hashlib.sha3_256).digest()
want = hmac.new(key, secret, hashlib.sha3_256).digest()
return hmac.compare_digest(got, want)
def mystery(x):
import hashlib, hmac
# Accept either a string or a (Python) integer.
if isinstance(x, str):
b = x.encode("utf-8", "strict")
elif isinstance(x, int):
b = str(x).encode("ascii", "strict")
else:
return False
# Quick reject: exact byte length required.
if len(b) != 16:
return False
def _ror8(v, r):
r &= 7
return v if r == 0 else (((v >> r) | (v << (8 - r))) & 0xFF)
# Reconstruct the hidden 16-byte secret via a chained reversible transform.
enc = (
224, 55, 155, 27,
157, 58, 133, 77,
242, 204, 129, 13,
167, 216, 87, 245
)
s = 0xAB
prev = 0x42
secret = bytearray(16)
for i, e in enumerate(enc):
s = (s * 3 + 29 + i) & 0xFF
w = e ^ prev
u = (w - (7 * i)) & 0xFF
r = (i * 2 + 1) & 7
t = _ror8(u, r)
secret[i] = t ^ s
prev = e
secret = bytes(secret)
# Derive a per-input key with computational cost.
iters = 25000 + (sum(b) & 2047)
salt = bytes((((j * 41 + 13) ^ (j // 3) ^ enc[j % 16]) & 0xFF for j in range(48)))
key = hashlib.pbkdf2_hmac('sha512', b + b[::-1], salt, iters, dklen=32)
# Compare keyed hashes (constant-time).
got = hmac.new(key, b, hashlib.sha3_256).digest()
want = hmac.new(key, secret, hashlib.sha3_256).digest()
return hmac.compare_digest(got, want)
def mystery(x):
import hashlib, hmac
# Normalize input to bytes.
if isinstance(x, str):
b = x.encode("utf-8", "strict")
elif isinstance(x, int):
b = str(x).encode("ascii", "strict")
else:
return False
# Fixed-length gate.
if len(b) != 28:
return False
def _ror8(v, r):
r &= 7
return ((v >> r) | ((v << (8 - r)) & 0xFF)) & 0xFF
# Hidden target, stored as a chained/rotated encoding.
enc = bytes((
163, 176, 37, 38, 220, 189, 1, 224, 171, 204, 71, 68, 148, 164,
147, 25, 199, 30, 230, 17, 99, 81, 178, 17, 90, 240, 174, 98
))
# Decode to reconstruct the secret (28 bytes).
s = 0xC7
prev = 0x3A
out = bytearray()
for i, e in enumerate(enc):
s = (s * 11 + 19 + i) & 0xFF
u = e ^ prev
r = (i % 7) + 1
tplus = _ror8(u, r)
t = (tplus - (5 * i)) & 0xFF
out.append(t ^ s)
prev = e
secret = bytes(out)
# Per-input expensive key schedule (depends on b, but salt depends on the hidden secret).
salt = hashlib.sha256(enc + b"|m|" + secret[::3] + bytes([enc[0] ^ enc[-1]])).digest()
iters = 35000 + ((enc[0] ^ enc[-1] ^ sum(b)) & 4095)
key = hashlib.pbkdf2_hmac("sha256", b[::-1] + bytes([len(b)]), salt, iters, dklen=32)
# If b == secret, HMACs match; otherwise you’re up against an (effectively) collision search.
got = hmac.new(key, b, hashlib.sha3_256).digest()
want = hmac.new(key, secret, hashlib.sha3_256).digest()
return hmac.compare_digest(got, want)
def mystery(x):
import hashlib, hmac
# Accept either a string or a (Python) integer.
if isinstance(x, str):
b = x.encode("utf-8", "strict")
elif isinstance(x, int):
b = str(x).encode("ascii", "strict")
else:
return False
# Quick reject: exact byte length required.
if len(b) != 16:
return False
def _ror8(v, r):
r &= 7
return v if r == 0 else (((v >> r) | (v << (8 - r))) & 0xFF)
# Reconstruct the hidden 16-byte secret via a chained reversible transform.
enc = (
20, 51, 252, 144, 230, 194, 226, 251,
10, 255, 187, 125, 79, 61, 192, 38
)
s = 0xB9
prev = 0xE2
secret = bytearray(16)
for i, e in enumerate(enc):
s = (s * 13 + 31 + i) & 0xFF
w = e ^ prev
u = (w - (17 * i)) & 0xFF
r = (i * 4 + 3) & 7
t = _ror8(u, r)
secret[i] = t ^ s
prev = e
secret = bytes(secret)
# Derive a per-input key with computational cost.
iters = 30000 + (sum(b) & 4095)
salt = bytes((((i * 89 + 47) ^ (i >> 3) ^ 0xC4) & 0xFF) for i in range(48))
key = hashlib.pbkdf2_hmac('sha512', b + b"mystery"[::-1], salt, iters, dklen=32)
# Compare keyed hashes (constant-time).
got = hashlib.blake2b(b, key=key, digest_size=32).digest()
want = hashlib.blake2b(secret, key=key, digest_size=32).digest()
return hmac.compare_digest(got, want)
def mystery(x):
import hashlib, hmac, unicodedata
# Normalize input to bytes (strings go through Unicode normalization first).
if isinstance(x, str):
x = unicodedata.normalize("NFKC", x)
b = x.encode("utf-8", "strict")
elif isinstance(x, int):
b = str(x).encode("ascii", "strict")
else:
return False
# Fixed-length gate (in bytes).
if len(b) != 31:
return False
def _ror8(v, r):
r &= 7
return ((v >> r) | ((v << (8 - r)) & 0xFF)) & 0xFF
# Encoded 31-byte target (reversible).
enc = bytes((
147, 34, 204, 163, 74, 7, 90, 33, 13, 236,
158, 71, 79, 219, 81, 106, 133, 169, 22, 145,
90, 75, 111, 163, 147, 209, 148, 68, 118, 206,
203
))
# Decode to reconstruct the hidden 31-byte secret.
secret = bytearray(31)
for i, e in enumerate(enc):
r = (i * 5 + 1) & 7
mask = (i * 17 + 93) & 0xFF
t = e ^ mask
secret[i] = _ror8(t, r)
secret = bytes(secret)
# Expensive per-input key schedule (depends on candidate and on the hidden secret).
salt = hashlib.sha256(
enc +
b"|m|" +
bytes([len(b), enc[0] ^ enc[-1]]) +
secret[::2] +
secret[::-3]
).digest()
iters = 22000 + ((sum(b) + (b[0] ^ b[-1]) + enc[7]) & 4095)
key = hashlib.pbkdf2_hmac(
"sha512",
b + b[::-1] + bytes([b[0] ^ 0xA7, b[-1] ^ 0x3C]),
salt,
iters,
dklen=32,
)
# Constant-time keyed hash comparison.
got = hashlib.blake2s(b, key=key[:16], digest_size=32).digest()
want = hashlib.blake2s(secret, key=key[:16], digest_size=32).digest()
return hmac.compare_digest(got, want)
def mystery(x):
import hashlib, hmac, unicodedata
# Normalize input to bytes (strings go through Unicode normalization first).
if isinstance(x, str):
x = unicodedata.normalize("NFKC", x)
b = x.encode("utf-8", "strict")
elif isinstance(x, int):
b = str(x).encode("ascii", "strict")
else:
return False
# Quick reject: exact byte length required.
if len(b) != 16:
return False
def _ror8(v, r):
r &= 7
return v if r == 0 else (((v >> r) | (v << (8 - r))) & 0xFF)
# Reconstruct the hidden 16-byte secret (as bytes) via a reversible per-byte transform.
enc = (
9, 91, 149, 54, 193, 221, 207, 189,
163, 219, 147, 71, 77, 3, 141, 215
)
secret = bytearray(16)
for i, t in enumerate(enc):
r = (i * 4 + 1) & 7
a = (i * 19 + 31) & 0xFF
xmask = (0xB6 ^ ((i * 13) & 0xFF)) & 0xFF
v = t ^ xmask
v = (v - a) & 0xFF
v = _ror8(v, r)
secret[i] = v
secret = bytes(secret)
# Derive a per-input key with computational cost.
iters = 28000 + (sum(b) & 2047)
salt = bytes((((i * 83 + 19) ^ (i >> 2) ^ 0x4F) & 0xFF) for i in range(40))
key = hashlib.pbkdf2_hmac('sha256', b + b[::-1], salt, iters, dklen=32)
# Compare keyed hashes (constant-time).
got = hashlib.blake2b(b, key=key, digest_size=32).digest()
want = hashlib.blake2b(secret, key=key, digest_size=32).digest()
return hmac.compare_digest(got, want)
def mystery(x):
import hashlib, hmac, unicodedata
# --- normalize input to bytes ---
if isinstance(x, str):
x = unicodedata.normalize("NFKC", x)
b = x.encode("utf-8", "strict")
elif isinstance(x, int):
# Integers are converted via their base-10 textual form.
b = str(x).encode("ascii", "strict")
else:
return False
# Fixed-size gate (bytes, not characters).
if len(b) != 33:
return False
def _ror8(v, r):
r &= 7
return v if r == 0 else (((v >> r) | (v << (8 - r))) & 0xFF)
# --- reconstruct a hidden 33-byte target (secret) ---
enc = bytes((
10, 223, 31, 67, 213, 185, 173, 193, 63, 15, 82,
122, 172, 147, 166, 15, 236, 10, 48, 25, 31,
122, 188, 150, 182, 212, 248, 223, 78, 78, 26,
33, 209
))
secret = bytearray(33)
for i, e in enumerate(enc):
a = (11 * i + 3) & 0xFF
r = (3 * i + 1) & 7
m = (0xA5 ^ ((17 * i + 93) & 0xFF)) & 0xFF
u = e ^ m
t0 = _ror8(u, r)
secret[i] = (t0 - a) & 0xFF
secret = bytes(secret)
# --- per-input expensive key schedule (depends on code object too) ---
code_f = hashlib.sha256(
mystery.__code__.co_code +
bytes([mystery.__code__.co_argcount, mystery.__code__.co_nlocals & 0xFF]) +
b"::mystery::"
).digest()
salt = hashlib.sha256(
code_f +
enc +
secret[::2] +
bytes([enc[0] ^ enc[-1]])
).digest()
iters = 26000 + ((code_f[0] ^ b[0] ^ b[-1] ^ sum(b)) & 4095)
key = hashlib.pbkdf2_hmac(
"sha512",
b + code_f[:9] + b[::-1] + bytes([len(b) ^ code_f[-1]]),
salt,
iters,
dklen=32
)
# Constant-time keyed hash comparison.
got = hashlib.blake2s(b, key=key[:16], digest_size=32).digest()
want = hashlib.blake2s(secret, key=key[:16], digest_size=32).digest()
return hmac.compare_digest(got, want)
def mystery(x):
import hashlib, hmac, unicodedata
# Normalize input to bytes (strings go through Unicode normalization first).
if isinstance(x, str):
x = unicodedata.normalize("NFKC", x)
b = x.encode("utf-8", "strict")
elif isinstance(x, int):
b = str(x).encode("ascii", "strict")
else:
return False
# Fixed-length gate.
if len(b) != 20:
return False
def _ror8(v, r):
r &= 7
return v if r == 0 else (((v >> r) | (v << (8 - r))) & 0xFF)
# Reconstruct the hidden 20-byte secret via a chained reversible transform.
enc = (
249, 23, 39, 120, 102, 29, 211, 0, 140, 224,
13, 91, 224, 173, 218, 238, 162, 32, 237, 84
)
secret = bytearray(20)
s = 0xA7
prev = 0x5E
for i in range(20):
e = enc[i]
w = e ^ prev
r = (i * 4 + 3) & 7
u = _ror8(w, r)
a = 11 * i + 5
t = (u - a) & 0xFF
secret[i] = t ^ s
prev = e
s = (s * 7 + 19) & 0xFF
secret = bytes(secret)
# Per-input expensive key schedule.
iters = 32000 + (sum(b) & 4095)
salt = bytes((((i * 53 + 11) ^ (i >> 1) ^ 0xB2) & 0xFF) for i in range(64))
key = hashlib.pbkdf2_hmac('sha256', b + b[::-1], salt, iters, dklen=32)
# Constant-time keyed hash comparison.
got = hmac.new(key, b, hashlib.sha3_256).digest()
want = hmac.new(key, secret, hashlib.sha3_256).digest()
return hmac.compare_digest(got, want)