encryptor

package
v0.0.0-...-15a7b9f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR_INVALID_SIGNATURE = -40001 // Signature verification failed
	ERROR_PARSE_XML         = -40002 // Parse XML failed
	ERROR_CALC_SIGNATURE    = -40003 // Calculating the signature failed
	ERROR_INVALID_AES_KEY   = -40004 // Invalid AESKey
	ERROR_INVALID_APP_ID    = -40005 // Check AppID failed
	ERROR_ENCRYPT_AES       = -40006 // AES EncryptionInterface failed
	ERROR_DECRYPT_AES       = -40007 // AES Decryption failed
	ERROR_INVALID_XML       = -40008 // Invaild XML
	EROOR_BASE64_ENCODE     = -40009 // Base64 encoding failed
	ERROR_BASE64_DECODE     = -40010 // Base64 decoding failed
	ERROR_XML_BULID         = -40011 // XML build failed
	ILLEGAL_BUFFER          = -41003 // Illegal buffer

)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(cipherText []byte, key []byte, iv []byte) ([]byte, error)

Decrypt

func PKCS7Pad

func PKCS7Pad(src []byte, blockSize int) []byte

PKCS7Pad pad.

func PKCS7Unpad

func PKCS7Unpad(src []byte, blockSize int) ([]byte, error)

PKCS7Unpad unpad.

func Signature

func Signature(s []string) string

Signature

Types

type Config

type Config struct {
	AppID          string `json:"app_id"` //appid
	Token          string `json:"token"`  //token
	EncodingAESKey string `json:"encoding_aes_key"`
	BlockSize      int
}

Config config

type Encryptor

type Encryptor struct {
	AppID     string
	Token     string
	AesKey    string
	BlockSize int
}

Encryptor encrypotr struct

func New

func New(config Config) *Encryptor

New return new point

func (*Encryptor) Decrypt

func (e *Encryptor) Decrypt(content []byte) ([]byte, error)

Decrypt decrypt message

func (*Encryptor) Encrypt

func (e *Encryptor) Encrypt(rawXML []byte, nonce string, timestamp int) ([]byte, error)

Encrypt encrypt message.

func (*Encryptor) GetToken

func (e *Encryptor) GetToken() string

GetToken is this necessary?

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error ecnryptor error

func NewError

func NewError(code int, message string) *Error

NewError new error

func (*Error) Error

func (e *Error) Error() string

Error

func (*Error) GetCode

func (e *Error) GetCode() int

GetCode return error code

func (*Error) GetMessage

func (e *Error) GetMessage() string

GetMessage alias of Error()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL