cybersecurity · intermediate · ~15 min

Detect weak passwords

Defence-in-depth — local heuristics never replace a proper password policy and hashing scheme.

Challenge

Implement int is_weak_password(const char *p) returning 1 if the password is weak by any of these (educational, not exhaustive) rules, else 0:

  1. Length < 8.
  2. All characters are the same.
  3. All characters are digits.
  4. Equals one of these common passwords: "password", "123456", "qwerty", "letmein".

Starter code

#include <string.h>

int is_weak_password(const char *p) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.