|
@@ -11,6 +11,7 @@ import (
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"github.com/go-admin-team/go-admin-core/logger"
|
|
"github.com/go-admin-team/go-admin-core/logger"
|
|
|
|
+ "github.com/tjfoc/gmsm/sm3"
|
|
)
|
|
)
|
|
|
|
|
|
type SingleMsg struct {
|
|
type SingleMsg struct {
|
|
@@ -27,9 +28,13 @@ type SendMsg struct {
|
|
MsgList []SingleMsg `json:"msgList"`
|
|
MsgList []SingleMsg `json:"msgList"`
|
|
}
|
|
}
|
|
|
|
|
|
-func sm3(data string) string {
|
|
|
|
|
|
+func SM3(data string) string {
|
|
// 这里应该实现SM3算法,由于Go标准库中没有直接支持,这里只是返回一个模拟的字符串
|
|
// 这里应该实现SM3算法,由于Go标准库中没有直接支持,这里只是返回一个模拟的字符串
|
|
- return "fake-sm3-hash"
|
|
|
|
|
|
+ h := sm3.New()
|
|
|
|
+ h.Write([]byte(data))
|
|
|
|
+ sum := h.Sum(nil)
|
|
|
|
+ logger.Debugf("digest value is: %x\n", sum)
|
|
|
|
+ return string(sum)
|
|
}
|
|
}
|
|
|
|
|
|
func (e *EventHandler) SendMsg() *EventHandler {
|
|
func (e *EventHandler) SendMsg() *EventHandler {
|
|
@@ -61,7 +66,7 @@ func (e *EventHandler) SendMsg() *EventHandler {
|
|
headers["x-system-key"] = appkey
|
|
headers["x-system-key"] = appkey
|
|
headers["x-system-nonce"] = nonce.String()
|
|
headers["x-system-nonce"] = nonce.String()
|
|
headers["x-system-timestamp"] = fmt.Sprintf("%d", timestamp)
|
|
headers["x-system-timestamp"] = fmt.Sprintf("%d", timestamp)
|
|
- headers["x-system-token"] = sm3(appkey + fmt.Sprintf("%d", timestamp) + appsecret + nonce.String())
|
|
|
|
|
|
+ headers["x-system-token"] = SM3(appkey + fmt.Sprintf("%d", timestamp) + appsecret + nonce.String())
|
|
|
|
|
|
// set smsContent
|
|
// set smsContent
|
|
// 所属系统:{{app_name}}
|
|
// 所属系统:{{app_name}}
|