#crypto/password
Xu 0.16.0 API
导入方式: #crypto/password
公开 API: 6 函数, 0 方法, 0 类型, 0 常量, 0 方法集
标准库包 `#crypto/password`。
pbkdf2_hmac_sha256
pub fn pbkdf2_hmac_sha256(password string, salt string, iterations int, key_len int) string
用途
执行 pbkdf2 hmac sha256 操作。失败时抛出错误,调用方需处理或继续传播。
参数
password string- password(string)
salt string- salt(string)
iterations int- iterations(int)
key_len int- key_len(int)
返回值
string — 结果字符串
hkdf_expand_sha256
pub fn hkdf_expand_sha256(prk &string, info &string, key_len int) string
用途
执行 hkdf expand sha256 操作。失败时抛出错误,调用方需处理或继续传播。
参数
prk &string- prk(只读借用,调用方仍持有原值;类型 &string)
info &string- info(只读借用,调用方仍持有原值;类型 &string)
key_len int- key_len(int)
返回值
string — 结果字符串
hash
pub fn hash(password string) string
用途
哈希。
参数
password string- password(string)
返回值
string — 结果字符串
hash_iter
pub fn hash_iter(password string, iterations int) string
用途
执行 hash iter 操作。失败时抛出错误,调用方需处理或继续传播。
参数
password string- password(string)
iterations int- iterations(int)
返回值
string — 结果字符串
verify
pub fn verify(encoded string, password string) bool
用途
校验数字签名是否有效。
参数
encoded string- encoded(string)
password string- password(string)
返回值
bool — 是否成立