1. Generate
Uses crypto.getRandomValues with rejection sampling, so each digit is uniform.
Interactive tool
Generate a PIN with a cryptographically secure random source, store only a salted hash of it, and verify attempts the way a real login system should.
Uses crypto.getRandomValues with rejection sampling, so each digit is uniform.
Stores a random salt and a PBKDF2-SHA256 hash. The PIN itself is discarded.
Re-derives the hash and compares it in constant time. Five failures lock the attempts.
A PIN is short, so the defences around it matter more than the PIN itself.