cybersecurity · intermediate · ~15 min · safe pentest lab
Map a bare hex digest to its bit-length (128/160/256).
Before cracking, identify the algorithm family. Implement:
int digest_bits(const char *h);
If h is entirely hex digits and 32/40/64 chars long, return 128/160/256 respectively (MD5-family / SHA-1 / SHA-256). Otherwise return -1.
A candidate hash string.
128, 160, 256, or -1.
Every character must be a hex digit; length must match exactly.
#include <stddef.h>
/* A pure-hex digest of 32/40/64 chars -> 128/160/256 bits (MD5-family/SHA-1/SHA-256). Else -1. */
int digest_bits(const char *h){ (void)h; return -1; }
Only checking length without validating hex; distinguishing MD5 from NTLM by length alone (you can't — both are 128-bit).
Uppercase hex is valid; 33 hex chars is -1.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.