如何将Laravel项目密码迁移到Go项目?

时间:2018-04-11 01:27:51

标签: laravel go password-hash

有一个Laravel项目,但现在已经重构为Go项目。

如何使用Go?

验证使用Laravel保存的用户密码

[更新]

我在[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class]]] setTintColor:UIColorFromRGB(0x3EA1EC)];

中使用Hash::make($password)商店密码

1 个答案:

答案 0 :(得分:0)

我使用以下代码解决了问题

import "golang.org/x/crypto/bcrypt"

func Hash(str string) (string, error) {
    hashed, err := bcrypt.GenerateFromPassword([]byte(str), bcrypt.DefaultCost)
    return string(hashed), err
}

func IsSame(str string, hashed string) bool {
    return bcrypt.CompareHashAndPassword([]byte(hashed), []byte(str)) == nil
}
相关问题