🔑
Security

Password Policy for Website Users: Modern Rules That Work

19.11.2026
← All articles

Every developer who launches an online store, a clinic booking system or a training centre portal eventually faces the same question: what passwords should users be allowed to choose? Many sites still demand "at least one capital letter, one digit and one symbol" and force a change every 90 days. In practice these rules do not improve security; they push people towards predictable choices like Parol2024!. The modern approach focuses on length, rejects known breached passwords and stores them properly on the server.

Why complexity rules fail

People naturally pick something easy to remember. When a site demands a capital letter and a symbol, users capitalise the first letter and append an exclamation mark and the year. Cracking tools try exactly these patterns first, so the password looks complex but stays weak. NIST's digital identity guidelines (SP 800-63B) likewise recommend dropping mandatory composition rules and periodic changes in favour of length and a blocklist. Forced rotation backfires too: users just increment a number at the end. Ask for a change only when there is evidence of compromise, such as a database leak or a suspicious login.

The core of a good policy

Checking breached passwords

The Pwned Passwords service from Have I Been Pwned lets you check a password safely: you send only the first 5 characters of its SHA-1 hash and compare the returned list locally, so the password never leaves your server.

function parol_sizganmi(string $parol): bool {
    $sha1 = strtoupper(sha1($parol));
    $prefiks = substr($sha1, 0, 5);
    $qoldiq = substr($sha1, 5);
    $javob = @file_get_contents('https://api.pwnedpasswords.com/range/' . $prefiks);
    if ($javob === false) {
        return false; // do not block sign-up if the service is down
    }
    foreach (explode("\n", $javob) as $qator) {
        [$xesh] = explode(':', trim($qator));
        if ($xesh === $qoldiq) {
            return true;
        }
    }
    return false;
}

If it returns true, tell the user clearly that the password appears in known breaches and ask for another one.

Storing passwords correctly

A policy is worthless if passwords sit in the database as plain text or plain MD5, which modern GPUs reverse very quickly. Use deliberately slow algorithms such as bcrypt or Argon2id. PHP's built-in functions add the salt automatically:

$xesh = password_hash($parol, PASSWORD_DEFAULT);

if (password_verify($kiritilgan, $xesh)) {
    if (password_needs_rehash($xesh, PASSWORD_DEFAULT)) {
        $yangi = password_hash($kiritilgan, PASSWORD_DEFAULT);
        // save $yangi to the database
    }
}

password_needs_rehash silently upgrades old hashes at the next login if the default algorithm or cost changes. Give the column at least VARCHAR(255).

Limiting login attempts

Count consecutive failures per account and per IP address, and after around five errors slow down logins for a few minutes or show a captcha. Avoid permanent lockouts, which let attackers deliberately block other people's accounts, and keep the error neutral: "Incorrect login or password".

Example: an online store in Tashkent

An appliance shop in Chilanzar opened customer accounts on misol.uz. Its old form required six characters and a digit, with MD5 storage. The new policy raised the minimum to 10 characters, allowed up to 128, added the breach check and moved to password_hash; old MD5 hashes are re-hashed when each user next logs in successfully. Staff accounts in the admin panel now require two-factor authentication, and the site runs over HTTPS with a free, auto-renewing Let's Encrypt certificate on sayt.uz hosting.

Do not forget password reset

Attackers often target the reset flow instead of the password. Reset tokens should be random, long, single-use and expire quickly; bin2hex(random_bytes(32)) is enough, and store only a hash of the token. After a successful change, end the user's other sessions and send a notification email.

Related articles

🚫 Your IP Is Blacklisted: How to Get Delisted from Spamhaus 🔐 Hiding and protecting your admin panel: a layered approach 🛡️ Protecting wp-login.php from brute-force attacks 🚫 xmlrpc.php: should you disable it, and how to do it safely
🌐 Language
🇺🇿 O'zbek 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓