package
Version:
v3.0.930
Opens a new window with list of versions in this module.
Published: Nov 3, 2024
License: Apache-2.0
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
func CompareHashAndPassword(hashedPassword, plainPassword []byte) error
CompareHashAndPassword 验证密码是否正确(对比 已哈希过的密码 与 原始明文密码 是否匹配。).
@param hashedPassword GenerateFromPassword() 的返回值
@param plainPassword 密码明文
@return err == nil: 已哈希过的密码 与 原始明文密码 匹配
func GenerateFromPassword(password []byte, costArgs ...int) (hashedPassword []byte, err error)
GenerateFromPassword 加密用户密码(生成一个带盐(salt)的哈希值).
@param costArgs 不传参将使用默认值(bcrypt.DefaultCost)
PS:
(1) 通常用于安全地存储密码;
(2) 传参相同,多次执行的结果不同.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.