Standard library / crypto/md5

crypto/md5.New()

Create an incremental MD5 hash. Write accepts successive chunks; Sum appends the digest without consuming the hash state. Cryptographically broken for collision resistance; use only for unavoidable legacy compatibility, never new signatures or adversarial integrity checks. Expected stdout: '900150983cd24fb0d6963f7d28e17f72\n'.

Formal Syntax & Structure

go syntaxgo
func New() hash.Hash

Return Value

hash.Hash

Fresh MD5 hash instance.

Working Example

Example Snippetgo
package main
import (  "crypto/md5"  "fmt")
func main() {  h := md5.New()  h.Write([]byte("a"))  h.Write([]byte("bc"))  fmt.Printf("%x\n", h.Sum(nil))}
Go Reference