ciphers

package
v0.0.0-...-1db1413 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OP_ENCRYPT = 0
	OP_DECRYPT = 1
)
View Source
const AEAD_MAX_SEGMENT_LENGTH = 0x3FFF

Variables

This section is empty.

Functions

func MD5

func MD5(data []byte) []byte

Types

type Encryptor

type Encryptor struct {
	Key          []byte
	KeyStr       string
	Method       string
	IVOut        []byte
	IVIn         []byte
	IVSent       bool
	IVLen        int
	IVBuf        *bytes.Buffer
	EncodeCipher *SSCipher
	DecodeCipher *SSCipher
}

func NewEncryptor

func NewEncryptor(method, key string) (result *Encryptor, err error)

func NewEncryptorWithIv

func NewEncryptorWithIv(method, key string, iv []byte) (result *Encryptor, err error)

func (*Encryptor) Decrypt

func (e *Encryptor) Decrypt(ciphertext []byte) (result []byte, err error)

func (*Encryptor) DecryptAll

func (e *Encryptor) DecryptAll(ciphertext []byte) (result, iv []byte, err error)

func (*Encryptor) Encrypt

func (e *Encryptor) Encrypt(src []byte) (result []byte, err error)

func (*Encryptor) EncryptAll

func (e *Encryptor) EncryptAll(src, iv []byte) (result []byte, err error)

func (*Encryptor) MustNewIV

func (e *Encryptor) MustNewIV() []byte

func (*Encryptor) NewIV

func (e *Encryptor) NewIV() (iv []byte, err error)

type ICipher

type ICipher interface {
	GetKey() []byte
	GetIv() []byte
	Encrypto([]byte) ([]byte, error)
	Decrypto([]byte) ([]byte, error)
}

type SSCipher

type SSCipher struct {
	OP int
	cipher.Stream
	cipher.AEAD
	cipher.BlockMode
	IV             []byte
	AEADWriteNonce []byte
	AEADReadNonce  []byte
	AEADReadBuffer *bytes.Buffer
	HeadSize       int
	Method         string
}

func NewCipher

func NewCipher(op int, method string, key, iv []byte) (*SSCipher, error)

func (*SSCipher) Decrypt

func (s *SSCipher) Decrypt(ciphertext []byte) (result []byte, err error)

func (*SSCipher) Encrypt

func (s *SSCipher) Encrypt(src []byte) (result []byte, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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