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.
16 lines
318 B
16 lines
318 B
package response
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"github.com/tjfoc/gmsm/sm4"
|
|
)
|
|
|
|
// Encryption 使用sm4算法加密数据
|
|
func Encryption(key string, data []byte) (string, error) {
|
|
ecbMsg, err := sm4.Sm4Ecb([]byte(key), data, true)
|
|
if err != nil {
|
|
return "", err
|
|
} else {
|
|
return hex.EncodeToString(ecbMsg), nil
|
|
}
|
|
}
|
|
|