test
This commit is contained in:
parent
901ae51019
commit
1588b9b7bd
|
|
@ -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)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue