encrypt

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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

func SM2DecryptAsn1(pass, privateKeyParam string) ([]byte, error)

SM2DecryptAsn1 使用SM2私钥解密ASN.1格式的加密数据 参数:

pass: 十六进制格式的加密密码字符串
privateKeyParam: 十六进制格式的SM2私钥参数

返回值:

[]byte: 解密后的原始数据
error: 解密过程中出现的错误,包括:
  - 空密码或私钥参数
  - 十六进制解码失败
  - 私钥解析失败
  - 解密失败

func SM2Encrypt

func SM2Encrypt(pubKey *sm2.PublicKey, data []byte) ([]byte, error)

SM2Encrypt 使用SM2公钥加密数据 参数:

pubKey: SM2公钥指针,不能为nil
data: 待加密数据,不能为空

返回值:

[]byte: 加密后的数据
error: 加密过程中出现的错误

func SM2EncryptAsn1

func SM2EncryptAsn1(pubKey *sm2.PublicKey, data []byte) ([]byte, error)

SM2EncryptAsn1 使用SM2公钥对数据进行ASN.1格式加密 参数:

pubKey - SM2公钥指针,不可为nil
data - 待加密数据,不可为空

返回:

[]byte - 加密后的ASN.1格式数据
error - 加密过程中出现的错误

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL