You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
901 B

package config
import (
"encoding/hex"
"github.com/tjfoc/gmsm/sm2"
"github.com/tjfoc/gmsm/x509"
)
var SdkConfig = &Config{}
type Config struct {
Url string // 接口地址
AppKey string // appKey
AppSecret string // appSecret
HexPrivateKey string // 16进制私钥
OtoSaasPublicKey string // 酷屏公钥
OtoSaasSm4Secret string // 酷屏sm4密钥
PrivateKey *sm2.PrivateKey // sm2私钥
Sm4Secret []byte
}
// InitOtoSaas @Title 初始化酷屏接口
func InitOtoSaas(config Config) error {
PrivateKey, err := x509.ReadPrivateKeyFromHex(config.HexPrivateKey)
if err != nil {
return err
}
config.PrivateKey = PrivateKey
sm4Secret, err := hex.DecodeString(config.OtoSaasSm4Secret)
if err != nil {
return err
}
config.Sm4Secret = sm4Secret
SdkConfig = &config
return nil
}