Loading

Golang MD5加密

package main

import (
	"crypto/md5"
	"encoding/hex"
	"fmt"
)

func main() {
	data := []byte("oldwei.com")
	md5Ctx := md5.New()
	md5Ctx.Write(data)
	cipherStr := md5Ctx.Sum(nil)
	fmt.Println(cipherStr)
	fmt.Printf("%x\n", md5.Sum(data))
	fmt.Printf("%x\n", cipherStr)
	fmt.Println(hex.EncodeToString(cipherStr))
}

运行结果:

[57 8 240 213 193 166 206 178 8 199 205 44 109 174 114 96]
3908f0d5c1a6ceb208c7cd2c6dae7260
3908f0d5c1a6ceb208c7cd2c6dae7260
3908f0d5c1a6ceb208c7cd2c6dae7260
posted @ 2021-10-28 14:40  老卫同学  阅读(111)  评论(0)    收藏  举报