1234567891011121314151617181920212223242526272829 |
- package main
- import (
- "crypto/md5"
- "encoding/hex"
- "fmt"
- "io"
- )
- func MD5Hash(text string) string {
-
- hasher := md5.New()
-
- io.WriteString(hasher, text)
-
- sum := hasher.Sum(nil)
-
- return hex.EncodeToString(sum)
- }
- func main() {
- text := "算法比赛.tar"
- hash := MD5Hash(text)
- fmt.Printf("The MD5 hash of '%s' is: %s\n", text, hash[0:8])
- }
|