Versions in this module Expand all Collapse all v0 v0.1.6 Jan 21, 2021 Changes in this version + const ErrBase64DecodeError + const ErrSignatureCheckError + const ErrSignatureCreateError + const ErrSigningMethodError + const SigningMethodRSA256 + const SigningMethodRSA384 + const SigningMethodRSA512 + var ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be PEM encoded") + var ErrNotECDSAPublicKey = errors.New("key is not a valid ECDSA public key") + var ErrNotRSAPrivateKey = errors.New("key is not a valid RSA private key") + var ErrNotRSAPublicKey = errors.New("key is not a valid RSA public key") + func AESDecrypt(encrypted string, key []byte) ([]byte, error) + func AESEncrypt(origin []byte, key []byte) (string, error) + func ECDSASign(data []byte, method string, privateKey *ecdsa.PrivateKey) (string, error) + func ECDSAVerify(content []byte, signature string, method string, publicKey *ecdsa.PublicKey) error + func HMACSHA256(data, key []byte) string + func HMACSHA512(data, key []byte) string + func PKCS7Padding(text []byte, size int) []byte + func PKCS7UnPadding(origData []byte) []byte + func ParseECDSAPrivate(data []byte) (*ecdsa.PrivateKey, error) + func ParseECDSAPublic(data []byte) (*ecdsa.PublicKey, error) + func ParseRSAPrivateKey(key []byte) (*rsa.PrivateKey, error) + func ParseRSAPublicKey(data []byte) (*rsa.PublicKey, error) + func RSADecrypt(encrypted string, privateKey *rsa.PrivateKey) ([]byte, error) + func RSAEncrypt(origData []byte, publicKey *rsa.PublicKey) (string, error) + func RSASign(data []byte, method string, privateKey *rsa.PrivateKey) (string, error) + func RSAVerify(content []byte, signature string, method string, publicKey *rsa.PublicKey) error + type ECDSAKey struct + func CreateECDSAKey() (*ECDSAKey, error) + func CreateECDSAKeyByPrivateKey(key *ecdsa.PrivateKey) *ECDSAKey + func (ek *ECDSAKey) EncodePrivateToPEM() ([]byte, error) + func (ek *ECDSAKey) EncodePublicToPem() ([]byte, error) + func (ek *ECDSAKey) PrivateKey() *ecdsa.PrivateKey + func (ek *ECDSAKey) PublicKey() *ecdsa.PublicKey + type RSAKey struct + func CreateRSAKey(size int) (*RSAKey, error) + func CreateRSAKeyByPrivateKey(privateKey *rsa.PrivateKey) *RSAKey + func (r *RSAKey) EncodePrivateToPEM() ([]byte, error) + func (r *RSAKey) EncodePublicToPEM() ([]byte, error) + func (r *RSAKey) PrivateKey() *rsa.PrivateKey + func (r *RSAKey) PublicKey() *rsa.PublicKey + func (r *RSAKey) Size() int