提交 8d418db0 authored 作者: 屈传平's avatar 屈传平

hcw

上级 5e2b8fdc
...@@ -41,10 +41,6 @@ func New(req *Config) *HcwClient { ...@@ -41,10 +41,6 @@ func New(req *Config) *HcwClient {
return hcwClient return hcwClient
} }
//const (
// secretKey = "b828a6aa972bcbe5e1e52ce4f24c467f" // 必须32字节
//)
type EncryptedResponse struct { type EncryptedResponse struct {
Data []byte `json:"data"` Data []byte `json:"data"`
Timestamp int64 `json:"timestamp"` Timestamp int64 `json:"timestamp"`
...@@ -65,7 +61,7 @@ func (s *HcwClient) EncryptWithSignature(data interface{}) (string, error) { ...@@ -65,7 +61,7 @@ func (s *HcwClient) EncryptWithSignature(data interface{}) (string, error) {
signatureString := string(jsonData) + strconv.FormatInt(timestamp, 10) signatureString := string(jsonData) + strconv.FormatInt(timestamp, 10)
// 计算HMAC-SHA256签名 // 计算HMAC-SHA256签名
signature := calculateHMAC([]byte(s.Config.SecretKey), signatureString) signature := calculateHMAC([]byte(s.Config.AppId), signatureString)
// 构建加密数据结构 // 构建加密数据结构
encryptedData := &EncryptedResponse{ encryptedData := &EncryptedResponse{
...@@ -81,7 +77,7 @@ func (s *HcwClient) EncryptWithSignature(data interface{}) (string, error) { ...@@ -81,7 +77,7 @@ func (s *HcwClient) EncryptWithSignature(data interface{}) (string, error) {
} }
// AES加密 // AES加密
block, err := aes.NewCipher([]byte(s.Config.SecretKey)) block, err := aes.NewCipher([]byte(s.Config.AppId))
if err != nil { if err != nil {
return "", fmt.Errorf("创建加密器失败: %v", err) return "", fmt.Errorf("创建加密器失败: %v", err)
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论