u/Stock_Hudso

▲ 94 r/codereview+1 crossposts

Hey everyone. I recently picked C back up after years away from it, and to get back into the mindset I implemented SHA-256 from scratch.

One deliberate choice: no pre-generated lookup tables. Both the K constants and the initial H values are derived at runtime from the first 64 primes, following the spec. The point was to understand where the constants come from, not just copy them in.

I also added a small interactive debug shell to inspect the internal state round by round.

Not production-ready, clearly. What I'm really after is feedback on code quality: structure, clarity, and anything that could be done better. I'm getting back into C and want to improve.

Note: I'm using camelCase rather than snake_case, also for function-like macros: just a personal style preference, happy to hear thoughts on that too.

Also: if you want to compile it, be aware that I'm using a GCC built-in function, portability is on my list.

Repo: https://git.dksengine.com/dks/SHA-256

u/Stock_Hudso — 11 days ago