20 lines
418 B
Go
20 lines
418 B
Go
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]
|
|
}
|