19 lines
226 B
Go
19 lines
226 B
Go
|
|
package sha1x
|
||
|
|
|
||
|
|
import (
|
||
|
|
"crypto/sha1"
|
||
|
|
"encoding/hex"
|
||
|
|
)
|
||
|
|
|
||
|
|
func Sha1(s string) string {
|
||
|
|
h := sha1.New()
|
||
|
|
h.Write([]byte(s))
|
||
|
|
|
||
|
|
bs := h.Sum(nil)
|
||
|
|
return hex.EncodeToString(bs)
|
||
|
|
|
||
|
|
// return fmt.Sprintf("%x", bs)
|
||
|
|
|
||
|
|
// return res
|
||
|
|
}
|