wrapper

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Zlib is the default Zlib Wrapper. This wrapper uses the default compression level. Use the 'NewZlib'
	// function to create a wrapper with a different level.
	Zlib = ZlibWrap(zlib.DefaultCompression)

	// Gzip is the default Gzip Wrapper. This wrapper uses the default compression level. Use the 'NewGzip'
	// function to create a wrapper with a different level.
	Gzip = GzipWrap(zlib.DefaultCompression)
)
View Source
const (
	// Hex is the Hex encoding Wrapper. This wraps the binary data as hex values.
	Hex = Simple(0x1)

	// Base64 is the Base64 Wrapper. This wraps the binary data as a Base64 byte string. This may be
	// combined with the Base64 transfrom.
	Base64 = Simple(0x2)
)

Variables

View Source
var ErrInvalid = xerr.New("provided crypto arguments cannot be nil")

ErrInvalid is returned when the arguments provided to any of the New* functions when the arguments are nil or empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	cipher.Block
	// contains filtered or unexported fields
}

Block is a struct that contains an IV and Block-based Cipher that can be used to Wrap/Unwrap with the specified encryption algorithm.

func NewBlock

func NewBlock(b cipher.Block, v []byte) (*Block, error)

NewBlock returns a Wrapper based on a Block Cipher, such as AES.

func (*Block) Unwrap

func (b *Block) Unwrap(r io.ReadCloser) (io.ReadCloser, error)

Unwrap satisfies the Wrapper interface.

func (*Block) Wrap

func (b *Block) Wrap(w io.WriteCloser) (io.WriteCloser, error)

Wrap satisfies the Wrapper interface.

type GzipWrap

type GzipWrap int8

GzipWrap is a alias for a Gzip compression level that implements the 'c2.Wrapper' interface.

func NewGzip

func NewGzip(level int) (GzipWrap, error)

NewGzip returns a Gzip compreession wrapper. This function will return and error if the commpression level is invalid.

func (GzipWrap) Unwrap

func (GzipWrap) Unwrap(r io.ReadCloser) (io.ReadCloser, error)

Unwrap satisfies the Wrapper interface.

func (GzipWrap) Wrap

func (g GzipWrap) Wrap(w io.WriteCloser) (io.WriteCloser, error)

Wrap satisfies the Wrapper interface.

type Simple

type Simple uint8

Simple is an alias that allows for wrapping multiple types of simple mathematic-based Wrappers. This alias implements the 'c2.Wrapper' interface.

func (Simple) Unwrap

func (s Simple) Unwrap(r io.ReadCloser) (io.ReadCloser, error)

Unwrap satisfies the Wrapper interface.

func (Simple) Wrap

func (s Simple) Wrap(w io.WriteCloser) (io.WriteCloser, error)

Wrap satisfies the Wrapper interface.

type Stream

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

Stream is a struct that contains a XMT Crypto Reader/Writer that can be used to Wrap/Unwrap using the specified streaming Reader and/or Writer types.

func NewCrypto

func NewCrypto(r crypto.Reader, w crypto.Writer) (*Stream, error)

NewCrypto returns a Wrapper based on the crypto.Writer and crypto.Reader interfaces, such as XOR and CBK.

func (*Stream) Unwrap

func (s *Stream) Unwrap(r io.ReadCloser) (io.ReadCloser, error)

Unwrap satisfies the Wrapper interface.

func (*Stream) Wrap

func (s *Stream) Wrap(w io.WriteCloser) (io.WriteCloser, error)

Wrap satisfies the Wrapper interface.

type ZlibWrap

type ZlibWrap int8

ZlibWrap is a alias for a Zlib compression level that implements the 'c2.Wrapper' interface.

func NewZlib

func NewZlib(level int) (ZlibWrap, error)

NewZlib returns a Zlib compreession wrapper. This function will return and error if the commpression level is invalid.

func (ZlibWrap) Unwrap

func (ZlibWrap) Unwrap(r io.ReadCloser) (io.ReadCloser, error)

Unwrap satisfies the Wrapper interface.

func (ZlibWrap) Wrap

func (z ZlibWrap) Wrap(w io.WriteCloser) (io.WriteCloser, error)

Wrap satisfies the Wrapper interface.

Jump to

Keyboard shortcuts

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