How to Hash Data with MD5 in Go (And Why You Shouldn't)

Use crypto/md5 for legacy checksums only; avoid MD5 for security and use SHA-256 instead.

MD5 is cryptographically broken and should not be used for security purposes; use SHA-256 instead. The standard library provides crypto/md5 for legacy compatibility, but crypto/sha256 is the recommended alternative.

package main

import (
	"crypto/md5"
	"fmt"
)

func main() {
	data := []byte("example data")
	hash := md5.Sum(data)
	fmt.Printf("%x\n", hash)
}

Do not use this for passwords, signatures, or any security-sensitive data.