encode

package
v1.1.14 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RndSeed int64 = -6544809196299914340
)

Variables

View Source
var (
	ErrUnknownAlgorithm     = errors.New("unknown encode algorithm")
	ErrEncodeMethodNotFound = errors.New("not found encode method")
)

Functions

func Cipher

func Cipher(algo cipher.Algorithm, mode cipher.Mode, key, iv []byte) utils.OptionFunc[option]

func Compress

func Compress(algo compress.Algorithm) utils.OptionFunc[option]

func Encode

func Encode(algo Algorithm) utils.OptionFunc[option]

func NewDecodeFunc

func NewDecodeFunc(algo Algorithm) func([]byte) ([]byte, error)

func NewEncodeFunc

func NewEncodeFunc(algo Algorithm) func([]byte) ([]byte, error)

func NewReader

func NewReader(algo Algorithm, r io.Reader) io.Reader

func NewWriter

func NewWriter(algo Algorithm, w io.Writer) io.Writer

Types

type Algorithm

type Algorithm uint8
const (
	AlgorithmUnknown Algorithm = iota
	AlgorithmHex
	AlgorithmBase32Std
	AlgorithmBase32Hex
	AlgorithmBase64Std
	AlgorithmBase64URL
	AlgorithmBase64RawStd // without padding
	AlgorithmBase64RawURL // without padding
)

func ParseAlgorithm

func ParseAlgorithm(s any) Algorithm

func (Algorithm) IsValid

func (e Algorithm) IsValid() bool

func (Algorithm) String

func (e Algorithm) String() string

func (Algorithm) Value

func (e Algorithm) Value() uint8

type Codecable

type Codecable interface {
	Encode(opts ...utils.OptionExtender) Codecable
	Decode(opts ...utils.OptionExtender) Codecable
	ToBytes() (dst []byte, err error)
	ToString() (dst string, err error)
}

func From

func From[T ~[]byte | ~string](src T) (c Codecable)

From a byte slice or a string, not concurrent safe

type EncodedType

type EncodedType int8
const (
	EncodedTypeUnknown EncodedType = iota
	EncodedTypeCipher
	EncodedTypeCompress
	EncodedTypeEncode
)

func ParseEncodedType

func ParseEncodedType(s any) EncodedType

func (EncodedType) IsValid

func (e EncodedType) IsValid() bool

func (EncodedType) String

func (e EncodedType) String() string

func (EncodedType) Value

func (e EncodedType) Value() uint8

type Streamable

type Streamable interface {
	Encode(dst io.Writer, src io.Reader) (n int64, err error)
	Decode(dst io.Writer, src io.Reader) (n int64, err error)
}

func NewCodecStream

func NewCodecStream(opts ...utils.OptionExtender) Streamable

Jump to

Keyboard shortcuts

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