💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# package md5 `import "crypto/md5"` md5包实现了MD5哈希算法,参见[RFC 1321](http://tools.ietf.org/html/rfc1321)。 ## Index * [Constants](#pkg-constants) * [func Sum(data []byte) [Size]byte](#Sum) * [func New() hash.Hash](#New) ### Examples * [New](#example-New) * [Sum](#example-Sum) ## Constants ``` const BlockSize = 64 ``` MD5字节块大小。 ``` const Size = 16 ``` MD5校验和字节数。 ## func [Sum](https://github.com/golang/go/blob/master/src/crypto/md5/md5.go#L129 "View Source") ``` func Sum(data []byte) [Size]byte ``` 返回数据data的MD5校验和。 Example ``` data := []byte("These pretzels are making me thirsty.") fmt.Printf("%x", md5.Sum(data)) ``` Output: ``` b0804ec967f48520697662a204f5fe72 ``` ## func [New](https://github.com/golang/go/blob/master/src/crypto/md5/md5.go#L49 "View Source") ``` func New() hash.Hash ``` 返回一个新的使用MD5校验的hash.Hash接口。 Example ``` h := md5.New() io.WriteString(h, "The fog is getting thicker!") io.WriteString(h, "And Leon's getting laaarger!") fmt.Printf("%x", h.Sum(nil)) ``` Output: ``` e2c569be17396eca2a2e3c11578123ed ```