Files
BitSrunLoginGo/pkg/srun/encode.go
2023-03-01 18:58:38 +08:00

24 lines
353 B
Go

package srun
import (
"crypto/md5"
"crypto/sha1"
"fmt"
"io"
)
// Md5 编码
func Md5(content string) string {
w := md5.New()
_, _ = io.WriteString(w, content)
return fmt.Sprintf("%x", w.Sum(nil))
}
// Sha1 编码
func Sha1(content string) string {
h := sha1.New()
h.Write([]byte(content))
bs := h.Sum(nil)
return fmt.Sprintf("%x\n", bs)
}