1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| import ( "crypto/md5" "encoding/hex" "fmt" "io" ) func main() { str := "www.topgoer.com" data := []byte(str) has := md5.Sum(data) md5str1 := fmt.Sprintf("%x", has) fmt.Println(md5str1) w := md5.New() io.WriteString(w, str) bw := w.Sum(nil) md5str2 := hex.EncodeToString(bw) fmt.Println(md5str2) }
|