You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
362 B
24 lines
362 B
2 years ago
|
package util
|
||
|
|
||
|
import (
|
||
|
"crypto/md5"
|
||
|
"crypto/sha256"
|
||
|
"encoding/hex"
|
||
|
)
|
||
|
|
||
|
// Md5 md5加密
|
||
|
func Md5(src string) string {
|
||
|
m := md5.New()
|
||
|
m.Write([]byte(src))
|
||
|
res := hex.EncodeToString(m.Sum(nil))
|
||
|
return res
|
||
|
}
|
||
|
|
||
|
// Sha256 Sha256加密
|
||
|
func Sha256(src string) string {
|
||
|
m := sha256.New()
|
||
|
m.Write([]byte(src))
|
||
|
res := hex.EncodeToString(m.Sum(nil))
|
||
|
return res
|
||
|
}
|