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.
basic_auth_password
basic_auth_username
client_ip
cookie
current_working_directory
environment_variable
exec
fetch
fetch_with_meta
hash_password
header
headers
hmac
link
path
persist_uploaded_file
protocol
random_string
read_file_as_data_url
read_file_as_text
request_body
request_body_base64
request_method
run_sql
set_variable
uploaded_file_mime_type
uploaded_file_name
uploaded_file_path
url_encode
user_info
user_info_token
variables
version