finclip-app-manager/infrastructure/utils/appSecret.go

20 lines
418 B
Go
Raw Normal View History

2023-10-31 14:07:26 +08:00
package utils
import (
"crypto/sha1"
"finclip-app-manager/infrastructure/config"
"fmt"
"math/rand"
"time"
)
//运行sha1加密生成appSecret
func GenAppSecret(sdk_key string) string {
rand.Seed(time.Now().Unix())
s := sdk_key + time.Now().String() + fmt.Sprintf("%s", rand.Intn(100000)) + config.Cfg.AppSecretSalt
h := sha1.New()
h.Write([]byte(s))
bs := h.Sum(nil)
return fmt.Sprintf("%x", bs)[16:32]
}