Store a password hash produced by a dedicated password-hashing library, never the raw password or a reversible encrypted copy. A fast general-purpose hash such as MD5 or plain SHA-256 is not appropriate for password storage.
For a new Python/Flask application, Argon2id is a suitable choice. The argon2-cffi PasswordHasher handles salts and stores the algorithm parameters in the encoded hash. Use its verification method on login; do not hash the submitted password again and compare strings, because each new hash uses a fresh salt.
The example below demonstrates the library API only, not a complete login system. Store the encoded value in a sufficiently sized text column and never log the supplied password. When verification succeeds, check whether the stored hash needs rehashing with your current parameters and update it if necessary.
Hashing makes offline guessing more expensive; it does not make a leaked database harmless. Weak passwords can still be guessed. Protect the application with HTTPS, rate-limited sign-in attempts, secure session cookies, appropriate MFA and a safe password-reset process.
Because your prototype contains plaintext passwords, stop further plaintext writes immediately. Plan a controlled migration to hashes and remove plaintext copies from normal storage. If those passwords may already have been exposed, hashing them now cannot undo that exposure; assess whether password resets and incident handling are needed.
See OWASP’s password-storage guidance and the argon2-cffi how-to. Benchmark the chosen settings on your deployment rather than reducing them simply to make a test faster.
Prepared with AI assistance by Tai. Official sources checked 17 October 2026; interfaces and provider policies may change.
No comments yet.