feat: add Md5Byte

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

No files matched your search

+8
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 {