cryptocodec

package
v1.1.93 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeadLength    = 4
	MaxPacketSize = 64 * 1024 * 1024
)

Variables

View Source
var (
	ErrPacketSizeExcced   = errors.New("codec: packet size exceed")
	ErrWrongMessageType   = errors.New("codec: wrong message type")
	ErrInvalidMessage     = errors.New("codec: invalid message")
	ErrInvalidRouteLength = errors.New("codec: invalid route length")
)

Functions

This section is empty.

Types

type AESGCM added in v1.1.3

type AESGCM struct{}

func (*AESGCM) Decrypt added in v1.1.3

func (*AESGCM) Decrypt(ciphertext, key []byte) ([]byte, error)

func (*AESGCM) Encrypt added in v1.1.3

func (*AESGCM) Encrypt(plaintext, key []byte) ([]byte, error)

func (*AESGCM) EncryptWithNonce added in v1.1.4

func (*AESGCM) EncryptWithNonce(plaintext, key []byte, nonce []byte) ([]byte, error)

type Codec

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

func NewCodec

func NewCodec(method Method, base64Key string) *Codec

func (*Codec) Entity

func (c *Codec) Entity(dictionary message.Dictionary) codec.CodecEntity

type CodecEntity

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

func NewCodecEntity

func NewCodecEntity(dictionary message.Dictionary, method Method, key []byte) *CodecEntity

func (*CodecEntity) DecodeMessage

func (c *CodecEntity) DecodeMessage(data []byte) (*message.Message, error)

func (*CodecEntity) DecodePacket

func (c *CodecEntity) DecodePacket(data []byte) ([]*packet.Packet, error)

func (*CodecEntity) EncodeMessage

func (c *CodecEntity) EncodeMessage(m *message.Message) ([]byte, error)

func (*CodecEntity) EncodePacket

func (c *CodecEntity) EncodePacket(packets []*packet.Packet) ([]byte, error)

func (*CodecEntity) String added in v1.1.49

func (c *CodecEntity) String() string

type Crypto added in v1.1.3

type Crypto struct {
	Method Method
	Key    []byte
}

func NewCrypto added in v1.1.3

func NewCrypto(method Method, key []byte) (*Crypto, error)

func (*Crypto) Decode added in v1.1.3

func (c *Crypto) Decode(data []byte) ([]byte, error)

func (*Crypto) Encode added in v1.1.3

func (c *Crypto) Encode(data []byte) ([]byte, error)

type Method added in v1.1.3

type Method int
const (
	AES128GCM Method = iota
	AES256GCM
)

func (Method) String added in v1.1.3

func (m Method) String() string

Jump to

Keyboard shortcuts

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