xor

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2022 License: BSD-3-Clause Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

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

Cipher defines resenje.org/cipher.StringCipher interface.

func New

func New(key []byte, opts ...Option) (c Cipher)

New returns a new Cipher instance with a given key.

func (Cipher) Decrypt added in v0.1.5

func (c Cipher) Decrypt(input []byte) ([]byte, error)

Decrypt decrypts input data produced by Encrypt. It performs a basic XOR encryption and validates Adler32 checksum.

func (Cipher) DecryptString

func (c Cipher) DecryptString(input string) (output string, err error)

DecryptString decrypts input string produced by EncryptString. It performs a basic XOR encryption and validates Adler32 checksum.

func (Cipher) Encrypt added in v0.1.5

func (c Cipher) Encrypt(input []byte) ([]byte, error)

Encrypt encrypts input data using XOR and Adler32 checksum for data validation.

func (Cipher) EncryptString

func (c Cipher) EncryptString(input string) (output string, err error)

EncryptString encrypts input string using XOR and Adler32 checksum for data validation.

type Option added in v0.1.2

type Option func(*Cipher)

Option is used to specify optional parameters to the New constructor.

func WithInputEncoder added in v0.1.2

func WithInputEncoder(e cipher.StringEncoder) Option

WithInputEncoder sets the EncryptString input data encoding. By default, no input data decoding of input data is performed. If the input data is always with the same encoding, encrypted strings can be reduced in size, buy specifying this option.

func WithOutputEncoder added in v0.1.2

func WithOutputEncoder(e cipher.StringEncoder) Option

WithOutputEncoder sets the EncryptString returned data encoding. By default, resenje.org/cipher.DefaultEncoder is used.

Jump to

Keyboard shortcuts

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