Sfoglia il codice sorgente

[REV] sm3 byte转换string优化

pujielan 1 mese fa
parent
commit
7e99f3f596
3 ha cambiato i file con 8 aggiunte e 5 eliminazioni
  1. 1 1
      config/settings.yml
  2. 1 1
      go.mod
  3. 6 3
      handler/sms.go

+ 1 - 1
config/settings.yml

@@ -106,6 +106,6 @@ settings:
       appSecret: "VXX8H0MzT7"
       url: "http://msa.zs.test.js.sgcc.com.cn/jssms/api/sendsmsbatch" 
       appsGroup: "opentelemetry-demo:18611342234,18722341127;demo:18511342234,18622341127"
-      smsTpl: "【江苏省电力公司\n所属系统:{{app_alias}}\n事件名称:{{events_name}}\n事件创建时间:{{date_time}}\n事件描述:{{events}}"
+      smsTpl: "【江苏省电力公司\n所属系统:{{app_alias}}\n事件名称:{{events_name}}\n事件创建时间:{{date_time}}\n事件描述:{{events}}"
       # sqlRecord: False
 

+ 1 - 1
go.mod

@@ -33,6 +33,7 @@ require (
 	github.com/swaggo/files v1.0.1
 	github.com/swaggo/gin-swagger v1.6.0
 	github.com/swaggo/swag v1.16.2
+	github.com/tjfoc/gmsm v1.4.1
 	github.com/unrolled/secure v1.0.8
 	github.com/uptrace/opentelemetry-go-extra/otelgorm v0.2.4
 	go.opentelemetry.io/collector/pdata v0.66.0
@@ -65,7 +66,6 @@ require (
 	github.com/hashicorp/go-version v1.6.0 // indirect
 	github.com/jackc/pgx/v5 v5.3.1 // indirect
 	github.com/microsoft/go-mssqldb v1.1.0 // indirect
-	github.com/tjfoc/gmsm v1.4.1 // indirect
 	github.com/uptrace/opentelemetry-go-extra/otelsql v0.2.4 // indirect
 	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0 // indirect
 	go.opentelemetry.io/proto/otlp v1.1.0 // indirect

+ 6 - 3
handler/sms.go

@@ -2,6 +2,7 @@ package handler
 
 import (
 	"crypto/rand"
+	"encoding/hex"
 	"encoding/json"
 	"fmt"
 	"io"
@@ -11,7 +12,8 @@ import (
 	"time"
 
 	"github.com/go-admin-team/go-admin-core/logger"
-	"github.com/tjfoc/gmsm/sm3"
+	// "github.com/tjfoc/gmsm/sm3"
+	sm3 "go-admin/utils/sm"
 )
 
 type SingleMsg struct {
@@ -33,8 +35,9 @@ func SM3(data string) string {
 	h := sm3.New()
 	h.Write([]byte(data))
 	sum := h.Sum(nil)
-	logger.Debugf("digest value is: %x\n", sum)
-	return string(sum)
+	logger.Infof("digest value is: %x\n", sum)
+	logger.Infof("digest value string: %s\n", hex.EncodeToString(sum))
+	return hex.EncodeToString(sum)
 }
 
 func (e *EventHandler) SendMsg() *EventHandler {