From 1588b9b7bdae4306394d82ec3108000a19a50591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Thu, 13 Mar 2025 19:04:01 +0800 Subject: [PATCH] test --- internal/pkg/cmb/sm2_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/internal/pkg/cmb/sm2_test.go b/internal/pkg/cmb/sm2_test.go index 86372e3..979ad9a 100644 --- a/internal/pkg/cmb/sm2_test.go +++ b/internal/pkg/cmb/sm2_test.go @@ -143,3 +143,26 @@ func TestCmbReply(t *testing.T) { } 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) +}