codec

package
v3.5.7 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultKey

func DefaultKey() *sm2.PrivateKey

DefaultKey 默认私钥

func DefaultPublicKeyBytes

func DefaultPublicKeyBytes() []byte

DefaultPublicKeyBytes 默认公钥

func DefaultPublicKeyHex

func DefaultPublicKeyHex() string

DefaultPublicKeyHex 默认公钥hex字符串

func DefaultSM2DecryptHex

func DefaultSM2DecryptHex(cipher string, noBase64 ...bool) (string, error)

DefaultSM2DecryptHex 默认密钥解密hex字符串

func HexEncodeToString

func HexEncodeToString(b []byte) string

HexEncodeToString hex编码为字符串

func Initialize

func Initialize()

Initialize 初始化默认私钥

func PEMtoPrivateKey

func PEMtoPrivateKey(raw []byte, pwd []byte) (*sm2.PrivateKey, error)

PEMtoPrivateKey PEM文件内容转私钥

func PEMtoPublicKey

func PEMtoPublicKey(raw []byte, pwd []byte) (*sm2.PublicKey, error)

PEMtoPublicKey PEM文件内容转公钥

func PrivateKeyToPEM

func PrivateKeyToPEM(privateKey *sm2.PrivateKey, pwd []byte) ([]byte, error)

PrivateKeyToPEM 私钥转PEM文件内容

func PublicKeyToBytes

func PublicKeyToBytes(publicKey *sm2.PublicKey) ([]byte, error)

PublicKeyToBytes marshals a public key to the bytes

func PublicKeyToHexString

func PublicKeyToHexString(publicKey *sm2.PublicKey) string

PublicKeyToHexString 公钥转hex字符串

func PublicKeyToPEM

func PublicKeyToPEM(publickKey *sm2.PublicKey, pwd []byte) ([]byte, error)

PublicKeyToPEM 公钥转PEM文件内容

func RSADecrypt

func RSADecrypt(input []byte) ([]byte, error)

RSADecrypt 私钥解密

func RSADefaultKey

func RSADefaultKey() *codec.RSA

RSAKey 默认私钥

func RSADefaultPublicKeyBase64

func RSADefaultPublicKeyBase64() string

func RSADefaultPublicKeyBytes

func RSADefaultPublicKeyBytes() []byte

func RSAEncrypt

func RSAEncrypt(input []byte) ([]byte, error)

RSAEncrypt 私钥加密

func RSAInitialize

func RSAInitialize()

RSAInitialize 初始化默认私钥

func RSAPublicKeyToBytes

func RSAPublicKeyToBytes(publicKey *rsa.PublicKey) ([]byte, error)

RSAPublicKeyToBytes marshals a public key to the bytes

func RSASignMd5

func RSASignMd5(data []byte) ([]byte, error)

RSASignMd5 使用RSAWithMD5算法签名

func RSASignSha1

func RSASignSha1(data []byte) ([]byte, error)

RSASignSha1 使用RSAWithSHA1算法签名

func RSASignSha256

func RSASignSha256(data []byte) ([]byte, error)

RSASignSha256 使用RSAWithSHA256算法签名

func ReadKey

func ReadKey(keyFile string, pwds ...[]byte) (privateKey *sm2.PrivateKey, err error)

ReadKey 读取私钥公钥

func SM2Decrypt

func SM2Decrypt(priv *sm2.PrivateKey, cipher []byte) ([]byte, error)

SM2Decrypt 解密

func SM2DecryptHex

func SM2DecryptHex(priv *sm2.PrivateKey, cipher string, noBase64 ...bool) (string, error)

SM2DecryptHex 解密

func SM2Encrypt

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

SM2Encrypt 加密

func SM2GenKey

func SM2GenKey() (*sm2.PrivateKey, error)

SM2GenKey 生成私钥和公钥

func SM2VerifySign

func SM2VerifySign(priv *sm2.PrivateKey, msg []byte) bool

SM2VerifySign 验签

func SaveKey

func SaveKey(privateKey *sm2.PrivateKey, keyFile string, pwds ...[]byte) error

SaveKey 保存私钥公钥

Types

type Codec

type Codec interface {
	Encode(raw string, keys ...string) string
	Decode(encrypted string, keys ...string) string
}

Jump to

Keyboard shortcuts

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