package main
import (
"log"
"time"
"golang.org/x/crypto/bcrypt"
)
func main() {
password := "secret"
for cost := 10; cost < 20; cost++ {
start := time.Now()
hashPwd(password, cost)
log.Println("cost =", cost, " 耗时:", time
bcrypt的cost值测试耗时结果
于 2023-04-18 17:00:54 首次发布
该代码示例展示了在Go语言中使用bcrypt库对密码进行加密的过程,随着加密成本(cost)的增加,耗时显著增长,从几十毫秒到数十秒不等,揭示了bcrypt加密的复杂性和安全性。

最低0.47元/天 解锁文章
547

被折叠的 条评论
为什么被折叠?



