1 Star 0 Fork 0

liangchao/gweb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
hash.go 489 Bytes
一键复制 编辑 原始数据 按行查看 历史
liangchao 提交于 4个月前 . 上传代码
package gweb
import "golang.org/x/crypto/bcrypt"
// TODO 更多支持,如选择加密方式
// BcryptHash 使用 bcrypt 对密码进行加密
func BcryptHash(password string) string {
bytes, _ := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
return string(bytes)
}
// BcryptCheck 对比明文密码和数据库的哈希值
func BcryptCheck(password, hash string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
return err == nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/makitdone/gweb.git
git@gitee.com:makitdone/gweb.git
makitdone
gweb
gweb
v1.0.7

搜索帮助