Documentation
¶
Index ¶
- func GenerateSM2KeyPair() (*sm2.PrivateKey, *sm2.PublicKey, error)
- func SM2Decrypt(privKey *sm2.PrivateKey, cipherText []byte) ([]byte, error)
- func SM2DecryptAsn1(pass, privateKeyParam string) ([]byte, error)
- func SM2Encrypt(pubKey *sm2.PublicKey, data []byte) ([]byte, error)
- func SM2EncryptAsn1(pubKey *sm2.PublicKey, data []byte) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSM2KeyPair ¶
func GenerateSM2KeyPair() (*sm2.PrivateKey, *sm2.PublicKey, error)
GenerateSM2KeyPair 生成SM2算法的公私钥对 返回: 私钥指针、公钥指针和可能的错误
func SM2Decrypt ¶
func SM2Decrypt(privKey *sm2.PrivateKey, cipherText []byte) ([]byte, error)
SM2Decrypt 使用SM2私钥解密数据 privKey: SM2私钥 cipherText: 待解密的密文 返回: 解密后的明文数据或错误信息
func SM2DecryptAsn1 ¶
SM2DecryptAsn1 使用SM2私钥解密ASN.1格式的加密数据 参数:
pass: 十六进制格式的加密密码字符串 privateKeyParam: 十六进制格式的SM2私钥参数
返回值:
[]byte: 解密后的原始数据 error: 解密过程中出现的错误,包括: - 空密码或私钥参数 - 十六进制解码失败 - 私钥解析失败 - 解密失败
func SM2Encrypt ¶
SM2Encrypt 使用SM2公钥加密数据 参数:
pubKey: SM2公钥指针,不能为nil data: 待加密数据,不能为空
返回值:
[]byte: 加密后的数据 error: 加密过程中出现的错误
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.