Files
nl-game-api/tools/genhash/main.go
2026-08-14 13:17:03 +08:00

23 lines
579 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 密码哈希生成工具:用于生成 SQL 种子数据中的 bcrypt 密码哈希
// 使用方式go run ./tools/genhash
package main
import (
"fmt"
"golang.org/x/crypto/bcrypt"
)
func main() {
// 需要生成哈希的明文密码列表(超管密码 + 演示账号密码)
passwords := []string{"qiqi991012", "123456"}
for _, p := range passwords {
// 使用默认成本因子(10)生成 bcrypt 哈希
hash, err := bcrypt.GenerateFromPassword([]byte(p), bcrypt.DefaultCost)
if err != nil {
panic(err)
}
fmt.Printf("%s => %s\n", p, string(hash))
}
}