Documentation ¶
Index ¶
- func Base64Decode(encoding *base64.Encoding, src []byte) ([]byte, error)
- func Base64Encode(encoding *base64.Encoding, src []byte) []byte
- func BytesToString(value []byte) string
- func HexDecode(src []byte) ([]byte, error)
- func HexEncode(src []byte) []byte
- func StringToBytes(s string) []byte
- type PrivateKey
- func (privateKey *PrivateKey) Decrypt(data []byte) ([]byte, error)
- func (privateKey *PrivateKey) DecryptASN1(data []byte) ([]byte, error)
- func (privateKey *PrivateKey) DecryptASN1FromBase64(encoding *base64.Encoding, data []byte) ([]byte, error)
- func (privateKey *PrivateKey) DecryptASN1FromHex(data []byte) ([]byte, error)
- func (privateKey *PrivateKey) DecryptFromBase64(encoding *base64.Encoding, data []byte) ([]byte, error)
- func (privateKey *PrivateKey) DecryptFromHex(data []byte) ([]byte, error)
- func (privateKey *PrivateKey) FromBase64(encoding *base64.Encoding, src, pwd []byte) error
- func (privateKey *PrivateKey) FromBase64File(encoding *base64.Encoding, filePath string, pwd []byte) (err error)
- func (privateKey *PrivateKey) FromHex(src, pwd []byte) (err error)
- func (privateKey *PrivateKey) FromHexFile(filePath string, pwd []byte) (err error)
- func (privateKey *PrivateKey) FromPEMFile(filePath string, pwd []byte) error
- func (privateKey *PrivateKey) FromRaw(src *sm2.PrivateKey) error
- func (privateKey *PrivateKey) FromRawBytes(src []byte, pwd []byte) (err error)
- func (privateKey *PrivateKey) GetPublicKey() PublicKey
- func (privateKey *PrivateKey) New() (err error)
- func (privateKey *PrivateKey) Sign(data []byte) ([]byte, error)
- func (privateKey *PrivateKey) SignToBase64(encoding *base64.Encoding, data []byte) ([]byte, error)
- func (privateKey *PrivateKey) SignToHex(data []byte) ([]byte, error)
- func (privateKey *PrivateKey) ToBase64(encoding *base64.Encoding, pwd []byte) (data []byte, err error)
- func (privateKey *PrivateKey) ToBase64File(encoding *base64.Encoding, filePath string, pwd []byte, perm fs.FileMode) (err error)
- func (privateKey *PrivateKey) ToHex(pwd []byte) (data []byte, err error)
- func (privateKey *PrivateKey) ToHexFile(filePath string, pwd []byte, perm fs.FileMode) (err error)
- func (privateKey *PrivateKey) ToPEMFile(filePath string, pwd []byte, perm fs.FileMode) error
- func (privateKey PrivateKey) ToRaw() *sm2.PrivateKey
- func (privateKey *PrivateKey) ToRawBytes(pwd []byte) ([]byte, error)
- type PublicKey
- func (publicKey *PublicKey) Encrypt(data []byte) (result []byte, err error)
- func (publicKey *PublicKey) EncryptASN1(data []byte) ([]byte, error)
- func (publicKey *PublicKey) EncryptASN1ToBase64(encoding *base64.Encoding, data []byte) ([]byte, error)
- func (publicKey *PublicKey) EncryptASN1ToHex(data []byte) ([]byte, error)
- func (publicKey *PublicKey) EncryptToBase64(encoding *base64.Encoding, data []byte) ([]byte, error)
- func (publicKey *PublicKey) EncryptToHex(data []byte) ([]byte, error)
- func (publicKey *PublicKey) FromBase64(encoding *base64.Encoding, src []byte) error
- func (publicKey *PublicKey) FromBase64File(encoding *base64.Encoding, filePath string) (err error)
- func (publicKey *PublicKey) FromHex(src []byte) error
- func (publicKey *PublicKey) FromHexFile(filePath string) (err error)
- func (publicKey *PublicKey) FromPEMFile(filePath string) (err error)
- func (publicKey *PublicKey) FromRaw(src *sm2.PublicKey) error
- func (publicKey *PublicKey) FromRawBytes(src []byte) (err error)
- func (publicKey *PublicKey) ToBase64(encoding *base64.Encoding) (data []byte, err error)
- func (publicKey *PublicKey) ToBase64File(encoding *base64.Encoding, filePath string, perm fs.FileMode) (err error)
- func (publicKey *PublicKey) ToHex() (data []byte, err error)
- func (publicKey *PublicKey) ToHexFile(filePath string, perm fs.FileMode) (err error)
- func (publicKey *PublicKey) ToPEMFile(filePath string, perm fs.FileMode) (err error)
- func (publicKey PublicKey) ToRaw() *sm2.PublicKey
- func (publicKey *PublicKey) ToRawBytes() ([]byte, error)
- func (publicKey *PublicKey) Verify(msg, sign []byte) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶
Base64解码
Types ¶
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
私钥
func (*PrivateKey) Decrypt ¶
func (privateKey *PrivateKey) Decrypt(data []byte) ([]byte, error)
私钥解密
func (*PrivateKey) DecryptASN1 ¶
func (privateKey *PrivateKey) DecryptASN1(data []byte) ([]byte, error)
私钥解密成asn.1编码的密文
func (*PrivateKey) DecryptASN1FromBase64 ¶
func (privateKey *PrivateKey) DecryptASN1FromBase64(encoding *base64.Encoding, data []byte) ([]byte, error)
私钥解密asn.1以及Base64编码的密文
func (*PrivateKey) DecryptASN1FromHex ¶
func (privateKey *PrivateKey) DecryptASN1FromHex(data []byte) ([]byte, error)
私钥解密asn.1以及Hex编码的密文
func (*PrivateKey) DecryptFromBase64 ¶
func (privateKey *PrivateKey) DecryptFromBase64(encoding *base64.Encoding, data []byte) ([]byte, error)
私钥解密Base64编码的密文
func (*PrivateKey) DecryptFromHex ¶
func (privateKey *PrivateKey) DecryptFromHex(data []byte) ([]byte, error)
私钥解密Hex编码的密文
func (*PrivateKey) FromBase64 ¶
func (privateKey *PrivateKey) FromBase64(encoding *base64.Encoding, src, pwd []byte) error
从Base64数据中获得私钥
func (*PrivateKey) FromBase64File ¶
func (privateKey *PrivateKey) FromBase64File(encoding *base64.Encoding, filePath string, pwd []byte) (err error)
从Base64文件中获得私钥
func (*PrivateKey) FromHex ¶
func (privateKey *PrivateKey) FromHex(src, pwd []byte) (err error)
从Hex数据中获得私钥
func (*PrivateKey) FromHexFile ¶
func (privateKey *PrivateKey) FromHexFile(filePath string, pwd []byte) (err error)
从Hex文件中获得私钥
func (*PrivateKey) FromPEMFile ¶ added in v1.2.0
func (privateKey *PrivateKey) FromPEMFile(filePath string, pwd []byte) error
从PEM编码的文件读取私钥
func (*PrivateKey) FromRaw ¶
func (privateKey *PrivateKey) FromRaw(src *sm2.PrivateKey) error
从原生类型中获得私钥
func (*PrivateKey) FromRawBytes ¶
func (privateKey *PrivateKey) FromRawBytes(src []byte, pwd []byte) (err error)
从[]byte中获得私钥
func (*PrivateKey) SignToBase64 ¶
私钥签名并转成Base64编码
func (*PrivateKey) SignToHex ¶
func (privateKey *PrivateKey) SignToHex(data []byte) ([]byte, error)
私钥签名并转成Hex编码
func (*PrivateKey) ToBase64 ¶
func (privateKey *PrivateKey) ToBase64(encoding *base64.Encoding, pwd []byte) (data []byte, err error)
私钥转为Base64数据
func (*PrivateKey) ToBase64File ¶
func (privateKey *PrivateKey) ToBase64File(encoding *base64.Encoding, filePath string, pwd []byte, perm fs.FileMode) (err error)
私钥保存为Base64编码的文件
func (*PrivateKey) ToHex ¶
func (privateKey *PrivateKey) ToHex(pwd []byte) (data []byte, err error)
私钥转为Hex编码
func (*PrivateKey) ToRawBytes ¶
func (privateKey *PrivateKey) ToRawBytes(pwd []byte) ([]byte, error)
获得私钥的[]byte类型
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
func (*PublicKey) EncryptASN1 ¶
公钥加密成asn.1编码
func (*PublicKey) EncryptASN1ToBase64 ¶
func (publicKey *PublicKey) EncryptASN1ToBase64(encoding *base64.Encoding, data []byte) ([]byte, error)
公钥加密成asn.1编码并转成Base64编码
func (*PublicKey) EncryptASN1ToHex ¶
公钥加密成asn.1编码并转成Hex编码
func (*PublicKey) EncryptToBase64 ¶
公钥加密并转成Base64编码
func (*PublicKey) EncryptToHex ¶
公钥加密并转成Hex编码
func (*PublicKey) FromBase64 ¶
从Base64编码中获得公钥
func (*PublicKey) FromBase64File ¶
从Base64编码的文件中获得公钥
func (*PublicKey) FromHexFile ¶
从Hex编码的文件中获得公钥
func (*PublicKey) FromPEMFile ¶ added in v1.2.0
从PEM编码的文件中读取公钥
func (*PublicKey) FromRawBytes ¶
从[]byte中获得公钥
func (*PublicKey) ToBase64File ¶
func (publicKey *PublicKey) ToBase64File(encoding *base64.Encoding, filePath string, perm fs.FileMode) (err error)
公钥保存为Base64编码的文件
func (*PublicKey) ToRawBytes ¶
公钥转为原生[]byte
Click to show internal directories.
Click to hide internal directories.