def mystery(x):
import hashlib
import hmac
if type(x) is not str:
return False
if not x.isascii():
return False
try:
a, b = x.split("|")
except ValueError:
return False
if len(a) != 56 or len(b) != 28:
return False
left = hashlib.sha256(a[::-1].encode("ascii")).hexdigest()
right = hmac.new(b"Jefe", b[::-1].encode("ascii"), hashlib.sha256).hexdigest()
return (
hmac.compare_digest(
left,
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1",
)
and hmac.compare_digest(
right,
"5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843",
)
)
def mystery(x):
if not isinstance(x, int) or not (0 <= x < 0x100000000):
return False
n = x
# Step 1: Right shift and XOR
n = (n ^ (n >> 17)) & 0xFFFFFFFF
# Step 2: Left shift and modular addition
n = (n + (n << 13)) & 0xFFFFFFFF
# Step 3: Another right shift and XOR
n = (n ^ (n >> 11)) & 0xFFFFFFFF
# Step 4: Another left shift and modular addition
n = (n + (n << 4)) & 0xFFFFFFFF
return n == 0x5a3c1e24
def mystery(x):
if type(x) is not str:
return False
if len(x) != 64 or any(c not in "0123456789abcdef" for c in x):
return False
try:
k = bytearray.fromhex(x)
except ValueError:
return False
p = (1 << 255) - 19
k[0] &= 248
k[31] &= 127
k[31] |= 64
n = int.from_bytes(k, "little")
def mul(n, u):
x1 = u % p
x2, z2 = 1, 0
x3, z3 = x1, 1
swap = 0
for t in range(254, -1, -1):
bit = (n >> t) & 1
swap ^= bit
if swap:
x2, x3 = x3, x2
z2, z3 = z3, z2
swap = bit
a = (x2 + z2) % p
aa = (a * a) % p
b = (x2 - z2) % p
bb = (b * b) % p
e = (aa - bb) % p
c = (x3 + z3) % p
d = (x3 - z3) % p
da = (d * a) % p
cb = (c * b) % p
x3n = (da + cb) % p
x3 = (x3n * x3n) % p
z3n = (da - cb) % p
z3 = (x1 * z3n * z3n) % p
x2 = (aa * bb) % p
z2 = (e * (aa + 121665 * e)) % p
if swap:
x2, x3 = x3, x2
z2, z3 = z3, z2
return (x2 * pow(z2, p - 2, p)) % p
y = mul(n, 9).to_bytes(32, "little")
return y[::-1] == bytes.fromhex(
"6a4e9baa8ea9a4ebf41a38260d3abf0d"
"5af73eb4dc7d8b7454a7308909f02085"
)
def mystery(x):
if not isinstance(x, str) or len(x) != 8:
return False
# Step 1: Mapping
# Each character is transformed using a bitwise XOR and a modular addition.
v = [((ord(c) ^ 0x55) + 123) & 0xFF for c in x]
# Step 2: Diffusion
# A linear transformation is applied using a circulant matrix modulo 10007.
r = []
for i in range(8):
s = 0
for j in range(8):
# The weight is a cyclic shift based on the relative position of i and j.
w = ((j - i) % 8) + 1
s = (s + w * v[j]) % 10007
r.append(s)
# The final result is checked against a specific target vector.
target = [6018, 5969, 6040, 5999, 5958, 5885, 6004, 5971]
return r == target
def mystery(x):
if type(x) is not int:
return False
n = int(
"114381625757888867669235779976146612010218296721242362562561842935"
"706935245733897830597123563958705058989075147599290026879543541"
)
if not (1 < x < n):
return False
return n % x == 0
def mystery(x):
if not isinstance(x, str) or len(x) != 16:
return False
try:
# Convert the 16-character string into two 64-bit big-endian integers
data = x.encode('ascii')
v0 = int.from_bytes(data[0:8], 'big')
v1 = int.from_bytes(data[8:16], 'big')
except (UnicodeEncodeError, ValueError):
return False
# Transformation parameters
mask = 0xFFFFFFFFFFFFFFFF
delta = 0x6A09E667F3BCC908
k = [0x510E527FADE682D1, 0x9B05688C2B3E6C1F]
s = 0
# 32 rounds of the cipher
for _ in range(32):
s = (s + delta) & mask
# Update the first half based on the second half and the current sum
v0 = (v0 + (((v1 << 7) ^ (v1 >> 11)) + k[0] ^ (v1 + s))) & mask
# Update the second half based on the newly updated first half
v1 = (v1 + (((v0 << 13) ^ (v0 >> 5)) + k[1] ^ (v0 + s))) & mask
# Check the result against the target values
return v0 == 0xc03513689408a287 and v1 == 0x82b9a781525a9829
def mystery(x):
if type(x) is not int:
return False
n = int(
"109417386415705274218097073220403576120037329454492059909138421314"
"763499842889347847179972578912673324976257528997818337970765372440"
"27146743531593354333897"
)
if not (1 < x < n):
return False
return pow(x, 65537, n) == 31337
def mystery(x):
if not isinstance(x, str) or len(x) != 8:
return False
try:
# Convert the 8-character string into two 32-bit big-endian integers
data = x.encode('ascii')
v0 = int.from_bytes(data[0:4], 'big')
v1 = int.from_bytes(data[4:8], 'big')
except (UnicodeEncodeError, ValueError):
return False
# A 32-round Feistel-like cipher
# A Feistel network ensures that the transformation is a permutation
# and can be reversed if the round function and round keys are known.
for i in range(32):
# A non-linear round function using modular exponentiation
# f(v, i) = ((v + i)^3 mod 2^32) ^ 0x55555555
# Modular exponentiation provides strong diffusion and makes the function
# significantly more difficult to linearize or reverse without computation.
f = (pow(v1 + i, 3, 0x100000000) ^ 0x55555555)
# The classic Feistel state update:
# New v0 is the old v1
# New v1 is the old v0 XORed with the round function's output
v0, v1 = v1, (v0 ^ f) & 0xFFFFFFFF
# Check the final state against the pre-calculated target values
return v0 == 0x6513d711 and v1 == 0x48710363
def mystery(x):
if type(x) is not str:
return False
if len(x) != 64 or any(c not in "0123456789abcdef" for c in x):
return False
try:
key = bytes(b ^ 0xA5 for b in bytes.fromhex(x))
except ValueError:
return False
def rotl(v, n):
return ((v << n) | (v >> (32 - n))) & 0xFFFFFFFF
def quarterround(s, a, b, c, d):
s[a] = (s[a] + s[b]) & 0xFFFFFFFF
s[d] = rotl(s[d] ^ s[a], 16)
s[c] = (s[c] + s[d]) & 0xFFFFFFFF
s[b] = rotl(s[b] ^ s[c], 12)
s[a] = (s[a] + s[b]) & 0xFFFFFFFF
s[d] = rotl(s[d] ^ s[a], 8)
s[c] = (s[c] + s[d]) & 0xFFFFFFFF
s[b] = rotl(s[b] ^ s[c], 7)
def words(bs):
return [int.from_bytes(bs[i:i + 4], "little") for i in range(0, len(bs), 4)]
state = [
0x61707865, 0x3320646E, 0x79622D32, 0x6B206574,
*words(key),
1,
*words(bytes.fromhex("000000090000004a00000000")),
]
s = state[:]
for _ in range(10):
quarterround(s, 0, 4, 8, 12)
quarterround(s, 1, 5, 9, 13)
quarterround(s, 2, 6, 10, 14)
quarterround(s, 3, 7, 11, 15)
quarterround(s, 0, 5, 10, 15)
quarterround(s, 1, 6, 11, 12)
quarterround(s, 2, 7, 8, 13)
quarterround(s, 3, 4, 9, 14)
out = b"".join(
((s[i] + state[i]) & 0xFFFFFFFF).to_bytes(4, "little")
for i in range(16)
)
return out[::-1] == bytes.fromhex(
"4e3c50a2e883d0cbb94e16ded19c12b5"
"a2028bd905d7c21409aa9f07466482d2"
"4e6cd4c39aaa22040368c033c7f4d1c7"
"c47120a31fdd0f5015593bd1e4e7f110"
)
def mystery(x):
if not isinstance(x, str) or len(x) != 8:
return False
try:
# Ensure the string is valid ASCII and get its bytes
data = x.encode('ascii')
except UnicodeEncodeError:
return False
# Convert the string into two 32-bit integers
# v0 and v1 are derived from the two halves of the 8-character string
v0 = int.from_bytes(data[0:4], 'big')
v1 = int.from_bytes(data[4:8], 'big')
# A 16-round transformation involving addition, rotation, and XOR.
# This structure provides high diffusion and non-linearity.
for i in range(16):
# Mix v1 into v0 using modular addition and a bitwise left rotation
v0 = (v0 + v1) & 0xFFFFFFFF
v0 = ((v0 << 13) | (v0 >> 19)) & 0xFFFFFFFF
v0 ^= (0x9E3779B1 + i) & 0xFFFFFFFF
# Mix the newly updated v0 into v1 similarly
v1 = (v1 + v0) & 0xFFFFFFFF
v1 = ((v1 << 17) | (v1 >> 15)) & 0xFFFFFFFF
v1 ^= (0x85EBCA6B + i) & 0xFFFFFFFF
# Check the final values against the pre-calculated target
return v0 == 0x9068062e and v1 == 0x2288339e