Posts  / #POST-211155
REDDIT

Predictable pattern in the numbers used to build SHA-256

N
Sep 19, 2025 · 23:50

Have a nice day!

import mpmath as mp
mp.mp.dps = 50

def fractional_sqrt(x: mp.mpf) -> mp.mpf:
r = mp.sqrt(x)
return r - mp.floor(r)

def sha256_frac_to_u32_hex(frac: mp.mpf) -> str:
val = int(mp.floor(frac * (1 << 32)))
return f"0x{val:08x}"

# First 8 primes from known values
primes = [2, 3, 5, 7, 11, 13, 17, 19]
iv_computed = []
for p in primes:
frac = fractional_sqrt(mp.mpf(p))
iv_computed.append(sha256_frac_to_u32_hex(frac))

iv_code = ["0x6a09e667", "0xbb67ae85", "0x3c6ef372", "0xa54ff53a", "0x510e527f", "0x9b05688c", "0x1f83d9ab", "0x5be0cd19"]
matches = all(iv_computed[i] == iv_code[i] for i in range(8))
print(f"IV match: {matches}")
print("Computed IV:", " ".join(iv_computed))