Files
Gogs/internal/cryptox/md5.go
ᴊᴏᴇ ᴄʜᴇɴ 36d56d5525 all: rename packages ending with "util" to end with "x" (#8182)
Co-authored-by: JSS <jss@unknwon.dev>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:25:19 -05:00

19 lines
333 B
Go

package cryptox
import (
"crypto/md5"
"encoding/hex"
)
// MD5 encodes string to hexadecimal of MD5 checksum.
func MD5(str string) string {
return hex.EncodeToString(MD5Bytes(str))
}
// MD5Bytes encodes string to MD5 checksum.
func MD5Bytes(str string) []byte {
m := md5.New()
_, _ = m.Write([]byte(str))
return m.Sum(nil)
}