Skip to content

Commit

Permalink
fix: sm4_filename_format #3652
Browse files Browse the repository at this point in the history
  • Loading branch information
fanfanyangyang authored and zhangzhw8 committed Mar 22, 2024
1 parent 0fc44cf commit 6936d38
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package service
import (
crand "crypto/rand"
"crypto/sha1"
"dbm-services/common/go-pubpkg/errno"
"dbm-services/mysql/priv-service/util"
"encoding/base64"
"encoding/hex"
"encoding/json"
Expand All @@ -13,9 +15,6 @@ import (
"os"
"time"

"dbm-services/common/go-pubpkg/errno"
"dbm-services/mysql/priv-service/util"

"github.com/spf13/viper"
)

Expand Down Expand Up @@ -185,7 +184,7 @@ func SM4(input string, vtype string) ([]byte, error) {
slog.Error("msg", "get random string error", err)
return nil, fmt.Errorf("get random string error: %s", err.Error())
}
name := fmt.Sprintf("%d.%x.%x.%s", sha1.Sum([]byte(input)), time.Now().UnixNano(), salt, vtype)
name := fmt.Sprintf("%d.%x.%x.%s", time.Now().UnixNano(), sha1.Sum([]byte(input)), salt, vtype)
inputName := fmt.Sprintf("%s.input", name)
outputName := fmt.Sprintf("%s.output", name)

Expand Down Expand Up @@ -224,7 +223,7 @@ func SM4(input string, vtype string) ([]byte, error) {
}
_, err = util.ExecShellCommand(false, cmd)
if err != nil {
slog.Error("msg", "exec command error", err)
slog.Error("msg", "cmd", cmd, "exec command error", err)
_ = inputFile.Close()
_ = os.Remove(inputName)
_ = os.Remove(outputName)
Expand Down

0 comments on commit 6936d38

Please sign in to comment.