This commit is contained in:
Yun
2023-12-27 19:00:14 +08:00
commit be8a2f84bd
12 changed files with 510 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
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
}
+14
View File
@@ -0,0 +1,14 @@
package sha1x_test
import (
"fmt"
"testing"
"code.yun.ink/pkg/encryptx/sha1x"
)
func TestSha1(t *testing.T) {
s := "sha1 this string"
r := sha1x.Sha1(s)
fmt.Println(r)
}