sqlpage.hash_password(password)

Introduced in SQLPage 0.7.2.

Hashes a password with the Argon2id variant and outputs it in the PHC string format, ready to store in your users table.

Every call generates a brand new cryptographic salt so that two people choosing the same password still end up with different hashes, which defeats rainbow-table attacks and lets you safely reveal only the hash.

Use this function only when creating or resetting a password (for example while inserting a brand new user): it writes the stored value. Later, at login time, the authentication component reads the stored hash, hashes the visitor's password with the embedded salt and parameters, and grants access only if they match.

Example

SELECT 'form' AS component;
SELECT 'username' AS name;
SELECT 'password' AS name, 'password' AS type;

INSERT INTO users (name, password_hash) VALUES (:username, sqlpage.hash_password(:password));

Try online

You can try the password hashing function on this page.

Parameters

password

The password to hash.