1 Star 0 Fork 0

窦雪峰 / go-common

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
password.go 429 Bytes
一键复制 编辑 原始数据 按行查看 历史
douxuefeng 提交于 2020-07-29 15:05 . go common
package go_common
import (
"fmt"
"golang.org/x/crypto/bcrypt"
)
func EncodePassword(password string) string {
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
if err != nil {
fmt.Println(err)
}
return string(hash)
}
func ValidatePassword(encodePassword, inputPassword string) bool {
err := bcrypt.CompareHashAndPassword([]byte(encodePassword), []byte(inputPassword))
return err == nil
}
Go
1
https://gitee.com/douxuefeng/go-common.git
git@gitee.com:douxuefeng/go-common.git
douxuefeng
go-common
go-common
dev

搜索帮助