Documentation ¶
Index ¶
- Constants
- Variables
- func Base64Decode(b []byte) ([]byte, error)
- func Base64Encode(b []byte) []byte
- func NewECBDecrypter(b cipher.Block) cipher.BlockMode
- func NewECBEncrypter(b cipher.Block) cipher.BlockMode
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(plantText []byte) []byte
- func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
- func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)
- func RSADecrypt(pri string, text string) string
- func RSAEncrypt(pub string, text string) string
- func SHA1(text ...string) string
- func ZeroPadding(ciphertext []byte, blockSize int) []byte
- func ZeroUnPadding(origData []byte) []byte
- type BizMsg
- type Cipher
- type CryptType
- type DataCrypt
- type ErrorCodeType
- type InstanceFunc
- type PrpCrypt
Constants ¶
View Source
const ( OK ErrorCodeType = 0 ValidateSignatureError = -40001 ParseXMLError = -40002 ComputeSignatureError = -40003 IllegalAesKey = -40004 ValidateAppidError = -40005 EncryptAESError = -40006 DecryptAESError = -40007 IllegalBuffer = -40008 EncodeBase64Error = -40009 DecodeBase64Error = -40010 GenReturnXMLError = -40011 )
error code types
Variables ¶
View Source
var ( ErrorKeyMustBePEMEncoded = errors.New("key must be pem encoded") ErrorNotECPublicKey = errors.New("key is not a valid ECDSA public key") ErrorNotECPrivateKey = errors.New("key is not a valid ECDSA private key") ErrorNotRSAPrivateKey = errors.New("key is not a valid RSA private key") ErrorNotRSAPublicKey = errors.New("key is not a valid RSA public key") )
all defined errors
View Source
var ErrorCode = map[string]ErrorCodeType{ "OK": OK, "ValidateSignatureError": ValidateSignatureError, "ParseXMLError": ParseXMLError, "ComputeSignatureError": ComputeSignatureError, "IllegalAesKey": IllegalAesKey, "ValidateAppidError": ValidateAppidError, "EncryptAESError": EncryptAESError, "DecryptAESError": DecryptAESError, "IllegalBuffer": IllegalBuffer, "EncodeBase64Error": EncodeBase64Error, "DecodeBase64Error": DecodeBase64Error, "GenReturnXMLError": GenReturnXMLError, }
ErrorCode ErrorCode
Functions ¶
func NewECBDecrypter ¶ added in v1.1.7
NewECBDecrypter returns a BlockMode which decrypts in electronic code book mode, using the given Block.
func NewECBEncrypter ¶ added in v1.1.7
NewECBEncrypter returns a BlockMode which encrypts in electronic code book mode, using the given Block.
func PKCS7Padding ¶
PKCS7Padding PKCS7Padding
func ParseRSAPrivateKeyFromPEM ¶
func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
ParseRSAPrivateKeyFromPEM Parse PEM encoded PKCS1 or PKCS8 private key
func ParseRSAPublicKeyFromPEM ¶
ParseRSAPublicKeyFromPEM Parse PEM encoded PKCS1 or PKCS8 public key
func ZeroPadding ¶ added in v1.1.7
func ZeroUnPadding ¶ added in v1.1.7
Types ¶
type BizMsg ¶
type BizMsg struct {
// contains filtered or unexported fields
}
BizMsg BizMsg
type Cipher ¶
type Cipher interface { Type() CryptType SetParameter(key string, val []byte) GetParameter(key string) []byte Encrypt([]byte) ([]byte, error) Decrypt(data []byte) ([]byte, error) }
Cipher ...
func CryptAES256ECB ¶ added in v1.1.7
func CryptAES256ECB() Cipher
type DataCrypt ¶
type DataCrypt struct {
// contains filtered or unexported fields
}
DataCrypt DataCrypt
type PrpCrypt ¶
type PrpCrypt struct {
// contains filtered or unexported fields
}
PrpCrypt PrpCrypt
func (*PrpCrypt) BytesLength ¶
BytesLength BytesLength
func (*PrpCrypt) LengthBytes ¶
LengthBytes LengthBytes
Click to show internal directories.
Click to hide internal directories.