feat: add wxshare

This commit is contained in:
Rogee
2025-04-30 17:06:10 +08:00
parent af0507d0c1
commit 42c1c17c0a
24 changed files with 313 additions and 147 deletions

View File

@@ -1,14 +1,24 @@
package wechat
import "math/rand"
import (
"crypto/sha1"
"encoding/hex"
"math/rand"
)
// RandomString generate random size string
func randomString(size int) (string, error) {
func randomString(size int) string {
// generate size string [0-9a-zA-Z]
const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
b := make([]byte, size)
for i := range b {
b[i] = chars[rand.Intn(len(chars))]
}
return string(b), nil
return string(b)
}
func hashSha1(input string) string {
h := sha1.New()
h.Write([]byte(input))
return hex.EncodeToString(h.Sum(nil))
}