package main import ( "fmt" "golang.org/x/crypto/bcrypt" ) func main() { password := "admin123" hash := "$2a$10$xx3wEU5GY6FbKd4Y7.r7SeyC2872l/bJwsrCx2KMdfWQ.tOHJ7Y4O" err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) if err == nil { fmt.Println("✅ 密码匹配成功") } else { fmt.Printf("❌ 密码不匹配: %v\n", err) } // 生成新的哈希测试 newHash, _ := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) fmt.Printf("新生成的哈希: %s\n", string(newHash)) }