Documentation ¶
Index ¶
- Variables
- func DefaultKey() *sm2.PrivateKey
- func DefaultPublicKeyBytes() []byte
- func DefaultPublicKeyHex() string
- func DefaultSM2DecryptHex(cipher string, noBase64 ...bool) (string, error)
- func HexEncodeToString(b []byte) string
- func PEMtoPrivateKey(raw []byte, pwd []byte) (*sm2.PrivateKey, error)
- func PEMtoPublicKey(raw []byte, pwd []byte) (*sm2.PublicKey, error)
- func PrivateKeyToPEM(privateKey *sm2.PrivateKey, pwd []byte) ([]byte, error)
- func PublicKeyToBytes(publicKey *sm2.PublicKey) ([]byte, error)
- func PublicKeyToHexString(publicKey *sm2.PublicKey) string
- func PublicKeyToPEM(publickKey *sm2.PublicKey, pwd []byte) ([]byte, error)
- func RSADecrypt(input []byte) ([]byte, error)
- func RSADefaultKey() *codec.RSA
- func RSADefaultPublicKeyBase64() string
- func RSADefaultPublicKeyBytes() []byte
- func RSAEncrypt(input []byte) ([]byte, error)
- func RSAPublicKeyToBytes(publicKey *rsa.PublicKey) ([]byte, error)
- func RSAReset()
- func RSASignMd5(data []byte) ([]byte, error)
- func RSASignSha1(data []byte) ([]byte, error)
- func RSASignSha256(data []byte) ([]byte, error)
- func ReadKey(keyFile string, pwds ...[]byte) (privateKey *sm2.PrivateKey, err error)
- func SM2Decrypt(priv *sm2.PrivateKey, cipher []byte) ([]byte, error)
- func SM2DecryptHex(priv *sm2.PrivateKey, cipher string, noBase64 ...bool) (string, error)
- func SM2Encrypt(pubKey *sm2.PublicKey, msg []byte) ([]byte, error)
- func SM2GenKey() (*sm2.PrivateKey, error)
- func SM2Reset()
- func SM2VerifySign(priv *sm2.PrivateKey, msg []byte) bool
- func SaveKey(privateKey *sm2.PrivateKey, keyFile string, pwds ...[]byte) error
- type Codec
- type RSA
- func (r *RSA) Decrypt(input []byte) ([]byte, error)
- func (r *RSA) DefaultKey() *codec.RSA
- func (r *RSA) DefaultPublicKeyBase64() string
- func (r *RSA) DefaultPublicKeyBytes() []byte
- func (r *RSA) Encrypt(input []byte) ([]byte, error)
- func (r *RSA) Reset()
- func (r *RSA) SignMd5(data []byte) ([]byte, error)
- func (r *RSA) SignSha1(data []byte) ([]byte, error)
- func (r *RSA) SignSha256(data []byte) ([]byte, error)
- type SM2
- func (s *SM2) DefaultDecryptHex(cipher string, noBase64 ...bool) (string, error)
- func (s *SM2) DefaultKey() *sm2.PrivateKey
- func (s *SM2) DefaultPublicKeyBytes() []byte
- func (s *SM2) DefaultPublicKeyHex() string
- func (s *SM2) ReadKey(keyFile string, pwds ...[]byte) (privateKey *sm2.PrivateKey, err error)
- func (s *SM2) Reset()
- func (s *SM2) SaveKey(privateKey *sm2.PrivateKey, keyFile string, pwds ...[]byte) error
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultRSA = NewRSA(`default`)
View Source
var DefaultSM2 = NewSM2(`default`)
Functions ¶
func DefaultSM2DecryptHex ¶
DefaultSM2DecryptHex 默认密钥解密hex字符串
func PEMtoPrivateKey ¶
func PEMtoPrivateKey(raw []byte, pwd []byte) (*sm2.PrivateKey, error)
PEMtoPrivateKey PEM文件内容转私钥
func PEMtoPublicKey ¶
PEMtoPublicKey PEM文件内容转公钥
func PrivateKeyToPEM ¶
func PrivateKeyToPEM(privateKey *sm2.PrivateKey, pwd []byte) ([]byte, error)
PrivateKeyToPEM 私钥转PEM文件内容
func PublicKeyToBytes ¶
PublicKeyToBytes marshals a public key to the bytes
func PublicKeyToHexString ¶
PublicKeyToHexString 公钥转hex字符串
func PublicKeyToPEM ¶
PublicKeyToPEM 公钥转PEM文件内容
func RSADefaultPublicKeyBase64 ¶
func RSADefaultPublicKeyBase64() string
func RSADefaultPublicKeyBytes ¶
func RSADefaultPublicKeyBytes() []byte
func RSAPublicKeyToBytes ¶
RSAPublicKeyToBytes marshals a public key to the bytes
func RSASignSha256 ¶
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 ¶
SM2DecryptHex 解密
Types ¶
type RSA ¶ added in v3.6.2
type RSA struct {
// contains filtered or unexported fields
}
func (*RSA) DefaultPublicKeyBase64 ¶ added in v3.6.2
func (*RSA) DefaultPublicKeyBytes ¶ added in v3.6.2
type SM2 ¶ added in v3.6.2
type SM2 struct {
// contains filtered or unexported fields
}
func (*SM2) DefaultDecryptHex ¶ added in v3.6.2
DefaultSM2DecryptHex 默认密钥解密hex字符串
func (*SM2) DefaultPublicKeyBytes ¶ added in v3.6.2
DefaultPublicKeyBytes 默认公钥
func (*SM2) DefaultPublicKeyHex ¶ added in v3.6.2
DefaultPublicKeyHex 默认公钥hex字符串
Click to show internal directories.
Click to hide internal directories.