#crypto/password
Xu 0.16.0 API
import: #crypto/password
counts: 6 functions, 0 methods, 0 types, 0 constants, 0 method sets
Password hashing & Key Derivation (PBKDF2-HMAC-SHA256 + HKDF-SHA256). Self-describing encoded hash for login $pbkdf2-sha256$<iterations>$<salt_b64>$<dk_b64> PBKDF2 work delegates to crypto/pbkdf2.key (precomputed SHA-256 midstates). XU-CT-USE: fixed-shape-only verify compares digests with crypto/subtle. Maximum PBKDF2 derived key length, including verified stored keys.
pbkdf2_hmac_sha256
pub fn pbkdf2_hmac_sha256(password string, salt string, iterations int, key_len int) string
Purpose
pbkdf2_hmac_sha256 returns key_len raw bytes (RFC 2898). Throws on failure; handle the error or propagate it to the caller.
Parameters
password string- password (string)
salt string- salt (string)
iterations int- iterations (int)
key_len int- key_len (int)
Returns
string — result string
hkdf_expand_sha256
pub fn hkdf_expand_sha256(prk &string, info &string, key_len int) string
Purpose
hkdf_expand_sha256 expands PRK to key_len bytes (RFC 5869 §2.3, max 255*32). Throws on failure; handle the error or propagate it to the caller.
Parameters
prk &string- prk (read-only borrow; caller keeps the original; type &string)
info &string- info (read-only borrow; caller keeps the original; type &string)
key_len int- key_len (int)
Returns
string — result string
hash
pub fn hash(password string) string
Purpose
hash returns $pbkdf2-sha256$iter$salt_b64$dk_b64.
Parameters
password string- password (string)
Returns
string — result string
hash_iter
pub fn hash_iter(password string, iterations int) string
Purpose
Hash iter. Throws on failure; handle the error or propagate it to the caller.
Parameters
password string- password (string)
iterations int- iterations (int)
Returns
string — result string
verify
pub fn verify(encoded string, password string) bool
Purpose
verify reports whether password matches an encoded hash.
Parameters
encoded string- encoded (string)
password string- password (string)
Returns
bool — true or false