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 ParsePEMBlocks(data []byte) []*pem.Block
- func ParsePKCS1PrivateKey(data []byte) (*rsa.PrivateKey, error)
- func ParsePKCS1PublicKey(data []byte) (*rsa.PublicKey, error)
- func ParsePKCS8PrivateKey(data []byte) (privateKey *rsa.PrivateKey, err error)
- func ParsePKIXPublicKey(data []byte) (publicKey *rsa.PublicKey, err error)
- func ParseRSAPrivateKey(data []byte) (privateKey *rsa.PrivateKey, version uint8, err error)
- func ParseRSAPublicKey(data []byte) (publicKey *rsa.PublicKey, version uint8, err error)
- func StringToBytes(s string) []byte
- type PrivateKey
- func (privateKey *PrivateKey) Decrypt(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 []byte) error
- func (privateKey *PrivateKey) FromBase64File(encoding *base64.Encoding, filePath string) error
- func (privateKey *PrivateKey) FromHex(src []byte) error
- func (privateKey *PrivateKey) FromPEMFile(filePath string) error
- func (privateKey *PrivateKey) FromRaw(src *rsa.PrivateKey) (err error)
- func (privateKey *PrivateKey) FromRawBytes(src []byte) (err error)
- func (privateKey *PrivateKey) GetPKCSVersion() uint8
- func (privateKey *PrivateKey) GetPublicKey() PublicKey
- func (privateKey *PrivateKey) New(bits int) (err error)
- func (privateKey *PrivateKey) Sign(data []byte, ch crypto.Hash) ([]byte, error)
- func (privateKey *PrivateKey) SignToBase64(encoding *base64.Encoding, data []byte, ch crypto.Hash) ([]byte, error)
- func (privateKey *PrivateKey) SignToHex(data []byte, ch crypto.Hash) ([]byte, error)
- func (privateKey *PrivateKey) ToBase64(encoding *base64.Encoding, version uint8) (data []byte, err error)
- func (privateKey *PrivateKey) ToHex(version uint8) (data []byte, err error)
- func (privateKey *PrivateKey) ToPEMFile(version uint8, filePath string) error
- func (privateKey PrivateKey) ToRaw() *rsa.PrivateKey
- func (privateKey *PrivateKey) ToRawBytes(version uint8) ([]byte, error)
- type PublicKey
- func (publicKey *PublicKey) Encrypt(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) FromHex(src []byte) error
- func (publicKey *PublicKey) FromPEMFile(filePath string) (err error)
- func (publicKey *PublicKey) FromRaw(src *rsa.PublicKey)
- func (publicKey *PublicKey) FromRawBytes(src []byte) (err error)
- func (publicKey *PublicKey) ToBase64(encoding *base64.Encoding) (data []byte, err error)
- func (publicKey *PublicKey) ToHex() (data []byte, err error)
- func (publicKey *PublicKey) ToPEMFile(version uint8, filePath string) error
- func (publicKey PublicKey) ToRaw() *rsa.PublicKey
- func (publicKey *PublicKey) ToRawBytes() []byte
- func (publicKey *PublicKey) Verify(data, sign []byte, ch crypto.Hash) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶
Base64解码
func ParsePEMBlocks ¶ added in v1.1.0
ParsePEMBlocks 解析PEM区块
func ParsePKCS1PrivateKey ¶ added in v1.1.0
func ParsePKCS1PrivateKey(data []byte) (*rsa.PrivateKey, error)
解析PKCS1私钥
func ParsePKCS1PublicKey ¶ added in v1.1.0
解析PKCS1公钥
func ParsePKCS8PrivateKey ¶ added in v1.1.0
func ParsePKCS8PrivateKey(data []byte) (privateKey *rsa.PrivateKey, err error)
解析PKCS8私钥
func ParsePKIXPublicKey ¶ added in v1.1.0
解析PKIX公钥
func ParseRSAPrivateKey ¶ added in v1.1.0
func ParseRSAPrivateKey(data []byte) (privateKey *rsa.PrivateKey, version uint8, err error)
解析RSA私钥,自动识别PKCS1和PKCS8
func ParseRSAPublicKey ¶ added in v1.1.0
解析RSA公钥,自动识别PKCS1和PKCS8
Types ¶
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
私钥
func (*PrivateKey) Decrypt ¶
func (privateKey *PrivateKey) Decrypt(data []byte) ([]byte, error)
私钥解密
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 []byte) error
从Base64数据中获得私钥
func (*PrivateKey) FromBase64File ¶
func (privateKey *PrivateKey) FromBase64File(encoding *base64.Encoding, filePath string) error
从Base64文件中获得私钥
func (*PrivateKey) FromPEMFile ¶ added in v1.1.0
func (privateKey *PrivateKey) FromPEMFile(filePath string) error
从PEM文件中获得私钥
func (*PrivateKey) FromRaw ¶
func (privateKey *PrivateKey) FromRaw(src *rsa.PrivateKey) (err error)
从原生类型中获得私钥
func (*PrivateKey) FromRawBytes ¶
func (privateKey *PrivateKey) FromRawBytes(src []byte) (err error)
从[]byte中获得私钥
func (*PrivateKey) GetPKCSVersion ¶ added in v1.1.0
func (privateKey *PrivateKey) GetPKCSVersion() uint8
获得PKCS版本
func (*PrivateKey) SignToBase64 ¶
func (privateKey *PrivateKey) SignToBase64(encoding *base64.Encoding, data []byte, ch crypto.Hash) ([]byte, error)
私钥签名并转成Base64编码
func (*PrivateKey) ToBase64 ¶
func (privateKey *PrivateKey) ToBase64(encoding *base64.Encoding, version uint8) (data []byte, err error)
私钥转为Base64数据
func (*PrivateKey) ToHex ¶
func (privateKey *PrivateKey) ToHex(version uint8) (data []byte, err error)
私钥转为Hex编码
func (*PrivateKey) ToPEMFile ¶ added in v1.1.0
func (privateKey *PrivateKey) ToPEMFile(version uint8, filePath string) error
私钥保存为PEM编码的文件
func (*PrivateKey) ToRawBytes ¶
func (privateKey *PrivateKey) ToRawBytes(version uint8) ([]byte, error)
获得私钥的[]byte类型
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
func (*PublicKey) EncryptToBase64 ¶
公钥加密并转成Base64编码
func (*PublicKey) EncryptToHex ¶
公钥加密并转成Hex编码
func (*PublicKey) FromBase64 ¶
从Base64编码中获得公钥
func (*PublicKey) FromPEMFile ¶ added in v1.1.0
从PEM文件中获得公钥
func (*PublicKey) FromRawBytes ¶
从[]byte中获得公钥
Click to show internal directories.
Click to hide internal directories.