后台面板
This commit is contained in:
@@ -59,13 +59,13 @@ hash = md5.FromBytes([]byte("hello")).
|
||||
|
||||
```go
|
||||
// 使用盐值加密(提高安全性)
|
||||
hashedPassword := md5.EncryptStringWithSalt("password123", "user@example.com")
|
||||
hashedPassword := md5.EncryptStringWithSalt("password123", "main@example.com")
|
||||
|
||||
// 使用前缀加密
|
||||
hashedValue := md5.EncryptStringWithPrefix("secret-data", "prefix-")
|
||||
|
||||
// 验证带盐值的哈希
|
||||
isValid := md5.VerifyMD5WithSalt("password123", "user@example.com", hashedPassword)
|
||||
isValid := md5.VerifyMD5WithSalt("password123", "main@example.com", hashedPassword)
|
||||
|
||||
// 使用HMAC-MD5提高安全性
|
||||
hmacHash := md5.MD5HMAC("message", "secret-key")
|
||||
|
||||
@@ -20,7 +20,7 @@ func Example() {
|
||||
fmt.Println("链式MD5:", chainHash)
|
||||
|
||||
// 使用盐值
|
||||
saltedHash := md5.EncryptStringWithSalt("password123", "user@example.com")
|
||||
saltedHash := md5.EncryptStringWithSalt("password123", "main@example.com")
|
||||
fmt.Println("加盐MD5:", saltedHash)
|
||||
|
||||
// 验证哈希
|
||||
@@ -63,9 +63,9 @@ func ExampleMD5_Sum() {
|
||||
|
||||
func ExampleEncryptStringWithSalt() {
|
||||
// 为用户密码加盐,通常使用用户唯一标识(如邮箱)作为盐值
|
||||
hash := md5.EncryptStringWithSalt("password123", "user@example.com")
|
||||
hash := md5.EncryptStringWithSalt("password123", "main@example.com")
|
||||
fmt.Println("盐值哈希长度:", len(hash))
|
||||
fmt.Println("是否为有效哈希:", md5.VerifyMD5WithSalt("password123", "user@example.com", hash))
|
||||
fmt.Println("是否为有效哈希:", md5.VerifyMD5WithSalt("password123", "main@example.com", hash))
|
||||
// Output:
|
||||
// 盐值哈希长度: 32
|
||||
// 是否为有效哈希: true
|
||||
|
||||
Reference in New Issue
Block a user