草庐IT

CompareHashAndPassword

全部标签

go - 为什么 bcrypt 库 CompareHashAndPassword 方法很慢?

我想比较密码并使用bcrypt库,但是CompareHashAndPassword方法非常慢。为什么这个方法很慢?varb[]byte=[]byte("1234")varbx[]byte=[]byte("$2a$14$RWV9NhWmlQmSoV9toM/k9OIzaNcYssCiauPVAljiX2NGhqvyxcOMy")fmt.Println("StartCompare:",time.Now().Format("2006-01-0215:04:05.000000"))err:=bcrypt.CompareHashAndPassword(bx,b)fmt.Println("Comp

hash - BCrypt 比较两个哈希值不相等

我有这个代码:u:=models.Users{}u=u.FindByEmail(登录.Email)密码:=[]byte(登录名.密码)哈希密码,错误:=bcrypt.GenerateFromPassword(密码,bcrypt.DefaultCost)如果错误!=无{panic(错误)错误=bcrypt.CompareHashAndPassword(hashedPassword,[]byte(u.Password))fmt.Println(错误)我最终得到这个错误:crypto/bcrypt:hashedPasswordisnotthehashofthegivenpassword但是我

hash - BCrypt 比较两个哈希值不相等

我有这个代码:u:=models.Users{}u=u.FindByEmail(登录.Email)密码:=[]byte(登录名.密码)哈希密码,错误:=bcrypt.GenerateFromPassword(密码,bcrypt.DefaultCost)如果错误!=无{panic(错误)错误=bcrypt.CompareHashAndPassword(hashedPassword,[]byte(u.Password))fmt.Println(错误)我最终得到这个错误:crypto/bcrypt:hashedPasswordisnotthehashofthegivenpassword但是我