1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-09 07:02:29 +08:00

feat: add Md5Byte

This commit is contained in:
dudaodong
2023-06-29 10:33:29 +08:00
parent 16c2df711b
commit 7d56da8108
5 changed files with 85 additions and 16 deletions

View File

@@ -40,6 +40,14 @@ func Md5String(s string) string {
return hex.EncodeToString(h.Sum(nil))
}
// Md5String return the md5 string of byte slice.
// Play: todo
func Md5Byte(data []byte) string {
h := md5.New()
h.Write(data)
return hex.EncodeToString(h.Sum(nil))
}
// Md5File return the md5 value of file.
func Md5File(filename string) (string, error) {
if fileInfo, err := os.Stat(filename); err != nil {