mirror of
https://github.com/beclab/Olares
synced 2026-04-21 21:47:56 +00:00
23 lines
380 B
Go
23 lines
380 B
Go
package utils
|
|
|
|
import (
|
|
"crypto/md5"
|
|
"encoding/base64"
|
|
"encoding/hex"
|
|
)
|
|
|
|
func MD5(str string) string {
|
|
hasher := md5.New()
|
|
|
|
hasher.Write([]byte(str))
|
|
hashBytes := hasher.Sum(nil)
|
|
return hex.EncodeToString(hashBytes)
|
|
}
|
|
|
|
func Base64decode(s string) (string, error) {
|
|
r, err := base64.StdEncoding.DecodeString(s)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return string(r), nil
|
|
}
|