cybersecurity · beginner · ~20 min
Bitmask flags as a structured error report.
Implement int password_check(const char *pw). Return a bitmask of failed requirements:
password (case-insensitive)Returns 0 if the password passes all checks.
Password policies are a balancing act: strong enough to resist common attacks, loose enough to be usable. NIST 800-63B has moved away from forced complexity in favor of length + breached-password checks, but understanding the legacy 'classic' rules is still important for compliance work.
ASCII string, null-terminated.
Bitmask.
Single pass over the string preferred.
int password_check(const char *pw) { /* TODO */ return 0; }
Treating space as a special char (it usually shouldn't be); using strcasestr (not standard — implement case-insensitive search yourself); using > instead of >= on the length check.
Empty string fails all. 12+ chars with only letters still fails digit and special.
O(strlen).
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.