Documentation ¶
Index ¶
- Variables
- func ComputeKey(pubKey, priKey *big.Int) (*big.Int, error)
- func EcbDecrypt(key, src []byte) ([]byte, error)
- func EcbDecryptBase64(key, src string) (string, error)
- func EcbEncrypt(key, src []byte) ([]byte, error)
- func EcbEncryptBase64(key, src string) (string, error)
- func Gunzip(bs []byte) ([]byte, error)
- func Gzip(bs []byte) []byte
- func Hmac(key []byte, body string) []byte
- func HmacBase64(key []byte, body string) string
- func NewECBDecrypter(b cipher.Block) cipher.BlockMode
- func NewECBEncrypter(b cipher.Block) cipher.BlockMode
- func NewPublicKey(bs []byte) *big.Int
- type DhKey
- type RsaDecrypter
- type RsaEncrypter
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidPriKey indicates the invalid private key. ErrInvalidPriKey = errors.New("invalid private key") // ErrInvalidPubKey indicates the invalid public key. ErrInvalidPubKey = errors.New("invalid public key") // ErrPubKeyOutOfBound indicates the public key is out of bound. ErrPubKeyOutOfBound = errors.New("public key out of bound") )
var ( // ErrPrivateKey indicates the invalid private key. ErrPrivateKey = errors.New("private key error") // ErrPublicKey indicates the invalid public key. ErrPublicKey = errors.New("failed to parse PEM block containing the public key") // ErrNotRsaKey indicates the invalid RSA key. ErrNotRsaKey = errors.New("key type is not RSA") )
var ErrPaddingSize = errors.New("padding size error")
ErrPaddingSize indicates bad padding size.
Functions ¶
func ComputeKey ¶
ComputeKey returns a key from public key and private key.
func EcbDecrypt ¶
EcbDecrypt decrypts src with the given key.
func EcbDecryptBase64 ¶
EcbDecryptBase64 decrypts base64 encoded src with the given base64 encoded key. The returned string is also base64 encoded.
func EcbEncrypt ¶
EcbEncrypt encrypts src with the given key.
func EcbEncryptBase64 ¶
EcbEncryptBase64 encrypts base64 encoded src with the given base64 encoded key. The returned string is also base64 encoded.
func HmacBase64 ¶
HmacBase64 returns the base64 encoded string of HMAC for body with the given key.
func NewECBDecrypter ¶
NewECBDecrypter returns an ECB decrypter.
func NewECBEncrypter ¶
NewECBEncrypter returns an ECB encrypter.
func NewPublicKey ¶
NewPublicKey returns a public key from the given bytes.
Types ¶
type RsaDecrypter ¶
type RsaDecrypter interface { Decrypt(input []byte) ([]byte, error) DecryptBase64(input string) ([]byte, error) }
RsaDecrypter represents a RSA decrypter.
func NewRsaDecrypter ¶
func NewRsaDecrypter(file string) (RsaDecrypter, error)
NewRsaDecrypter returns a RsaDecrypter with the given file.
type RsaEncrypter ¶
RsaEncrypter represents a RSA encrypter.
func NewRsaEncrypter ¶
func NewRsaEncrypter(key []byte) (RsaEncrypter, error)
NewRsaEncrypter returns a RsaEncrypter with the given key.