Policy type
pub type Policy = {min: Int where _ >= 8, max: Int where _ >= 64 and _ <= 1024} derive Eq, ShowHow long a password must and may be.
Package
Password policy after NIST SP 800-63B, and Argon2id hashing
0.1.0 MIT
sspur add passwords@^0.1.0or in sspur.toml:
passwords = { version = "^0.1.0" }Password policy and storage for SSPUR, after NIST SP 800-63B: a length range, no well-known passwords, nothing built from the account's own name, and Argon2id hashes.
use passwords.{default_policy, problem, hash, verify}
fn sign_up(email: Str, pw: Str) -> Res[Str, Str] ! rand
= match problem(default_policy(), pw, [email])
| some(why) => err(why)
| none => ok(hash(secret(pw)))
problem(policy, password, avoid) says what is wrong with a password, or none. avoid lists words it must not be built from, such as the email or user name.hash(password) returns an Argon2id hash with a random salt, and verify(password, stored) checks one in constant time.needs_rehash(stored) tells when a stored hash uses older parameters, so it can be upgraded at the next login.sspur add passwords
MIT licensed. Part of the web app that sspur new web-app creates.
pub type Policy = {min: Int where _ >= 8, max: Int where _ >= 64 and _ <= 1024} derive Eq, ShowHow long a password must and may be.
fn default_policy() -> Policy10 to 128 characters.
fn problem(p: Policy, pw: Str, avoid: List[Str]) -> Opt[Str]Why pw is not acceptable under p, or none. avoid holds words the password must not contain, such as the user's email address and the site's name.
fn hash(pw: Secret[Str]) -> Str ! randAn Argon2id hash of pw with a random salt, as a PHC string.
fn verify(pw: Secret[Str], stored: Str) -> BoolWhether pw matches stored, in constant time.
fn needs_rehash(stored: Str) -> BoolWhether stored was made with weaker parameters than hash uses now, so it should be replaced the next time the password is known.
| Version | Published | Commit | Source | Effects |
|---|---|---|---|---|
| 0.1.0 | 2026-10-16 | bcf011b00b | snapshot |