Documentation
¶
Index ¶
- Variables
- type RSAEncryptor
- func (encryptor *RSAEncryptor) Alg() string
- func (encryptor *RSAEncryptor) Decryption(ciphertext []byte) (plainText []byte, err error)
- func (encryptor *RSAEncryptor) Encrypt(data []byte) ([]byte, error)
- func (encryptor *RSAEncryptor) GenerateKey(bit int) (privateKey *rsa.PrivateKey, err error)
- func (encryptor *RSAEncryptor) LoadPrivateKeyByPath() (privateKey *rsa.PrivateKey, err error)
- func (encryptor *RSAEncryptor) LoadPublicKeyByPath() (publicKey *rsa.PublicKey, err error)
- func (encryptor *RSAEncryptor) ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
- func (encryptor *RSAEncryptor) ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
- func (encryptor *RSAEncryptor) ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)
- func (encryptor *RSAEncryptor) SavePrivateKeyByPath(path string) (err error)
- func (encryptor *RSAEncryptor) SavePublicKeyByPath(path string) (err error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type RSAEncryptor ¶
type RSAEncryptor struct {
CertificateSerialNo string // 签名证书序列号
PublicKeyPath string // 签名公钥路径
PublicKey *rsa.PublicKey // 签名公钥
PrivateKeyPath string // 签名私钥路径,会自动读取出*rsa.PrivateKey
PrivateKey *rsa.PrivateKey // 签名私钥
Hash crypto.Hash
}
func NewRSAEncryptor ¶
func NewRSAEncryptor(hash crypto.Hash) (encryptor *RSAEncryptor, err error)
func (*RSAEncryptor) Alg ¶
func (encryptor *RSAEncryptor) Alg() string
func (*RSAEncryptor) Decryption ¶
func (encryptor *RSAEncryptor) Decryption(ciphertext []byte) (plainText []byte, err error)
Decryption optHash recommend use crypto.SHA256 as hash
func (*RSAEncryptor) Encrypt ¶
func (encryptor *RSAEncryptor) Encrypt(data []byte) ([]byte, error)
Encrypt hash recommend use sha256.New() as hash
func (*RSAEncryptor) GenerateKey ¶
func (encryptor *RSAEncryptor) GenerateKey(bit int) (privateKey *rsa.PrivateKey, err error)
func (*RSAEncryptor) LoadPrivateKeyByPath ¶
func (encryptor *RSAEncryptor) LoadPrivateKeyByPath() (privateKey *rsa.PrivateKey, err error)
func (*RSAEncryptor) LoadPublicKeyByPath ¶
func (encryptor *RSAEncryptor) LoadPublicKeyByPath() (publicKey *rsa.PublicKey, err error)
func (*RSAEncryptor) ParseRSAPrivateKeyFromPEM ¶
func (encryptor *RSAEncryptor) ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
func (*RSAEncryptor) ParseRSAPrivateKeyFromPEMWithPassword ¶
func (encryptor *RSAEncryptor) ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
Parse PEM encoded PKCS1 or PKCS8 private key protected with password
func (*RSAEncryptor) ParseRSAPublicKeyFromPEM ¶
func (encryptor *RSAEncryptor) ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)
func (*RSAEncryptor) SavePrivateKeyByPath ¶
func (encryptor *RSAEncryptor) SavePrivateKeyByPath(path string) (err error)
func (*RSAEncryptor) SavePublicKeyByPath ¶
func (encryptor *RSAEncryptor) SavePublicKeyByPath(path string) (err error)
Click to show internal directories.
Click to hide internal directories.