1 Star 0 Fork 1

Yietion / go-utils

forked from 可乐烛光烟 / go-utils 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
password.go 512 Bytes
一键复制 编辑 原始数据 按行查看 历史
可乐烛光烟 提交于 2022-11-09 00:21 . Initial commit
/**
* @User: rysa
* @Created:2021/2/7 10:37 下午
* @File: password
* @Desc:
*/
package go_utils
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
}
1
https://gitee.com/yietion/go-utils.git
git@gitee.com:yietion/go-utils.git
yietion
go-utils
go-utils
master

搜索帮助