This commit is contained in:
李子铭 2025-03-13 19:04:01 +08:00
parent 901ae51019
commit 1588b9b7bd
1 changed files with 23 additions and 0 deletions

View File

@ -143,3 +143,26 @@ func TestCmbReply(t *testing.T) {
} }
t.Log(aa) t.Log(aa)
} }
func TestGenerateSm2KeyAndEncryptDecrypt(t *testing.T) {
priKey, pukKey := GenerateSm2Key()
t.Log("SM2私钥:", priKey, len(priKey))
t.Log("SM2公钥:", pukKey, len(pukKey))
content := `{"name":"zhangxx","phoneNo":"137xxxxxxxx"}`
xx, err := Encrypt(pukKey, content)
if err != nil {
t.Log(err)
return
}
t.Log(xx)
aa, err := Decrypt(priKey, xx)
if err != nil {
t.Log(err)
return
}
t.Log(aa)
}