You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
249 B
Go
19 lines
249 B
Go
1 year ago
|
package nbyte
|
||
|
|
||
|
import (
|
||
|
"crypto/md5"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
// Md5 Generate a 32-bit md5 bytes
|
||
|
func Md5(src any) []byte {
|
||
|
h := md5.New()
|
||
|
|
||
|
if s, ok := src.(string); ok {
|
||
|
h.Write([]byte(s))
|
||
|
} else {
|
||
|
h.Write([]byte(fmt.Sprint(src)))
|
||
|
}
|
||
|
return h.Sum(nil)
|
||
|
}
|