2022-11-24 23:37:34 +08:00
|
|
|
// Package encrypt
|
|
|
|
// @Link https://github.com/bufanyun/hotgo
|
2023-02-23 17:53:04 +08:00
|
|
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
2022-11-24 23:37:34 +08:00
|
|
|
// @Author Ms <133814250@qq.com>
|
|
|
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
|
|
|
//
|
|
|
|
package encrypt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/md5"
|
|
|
|
"fmt"
|
|
|
|
"hash/fnv"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Md5ToString 生成md5
|
|
|
|
func Md5ToString(str string) string {
|
|
|
|
return fmt.Sprintf("%x", md5.Sum([]byte(str)))
|
|
|
|
}
|
|
|
|
|
2023-01-18 16:23:39 +08:00
|
|
|
// Md5 生成md5
|
|
|
|
func Md5(b []byte) string {
|
|
|
|
return fmt.Sprintf("%x", md5.Sum(b))
|
|
|
|
}
|
|
|
|
|
2022-11-24 23:37:34 +08:00
|
|
|
func Hash32(b []byte) uint32 {
|
|
|
|
h := fnv.New32a()
|
|
|
|
h.Write(b)
|
|
|
|
return h.Sum32()
|
|
|
|
}
|