encoders

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

README

Encoders (Implant)

Mostly copied for util/encoders but the implant needs it's own implementation of the encoders package so that vendor dependencies works correctly. Unit tests for the server/encoders package should test interoperability.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EncoderModulus = uint64(65537)
	MaxN           = uint64(9999999)

	Base32EncoderID, _  = strconv.ParseUint(`{{.Encoders.Base32EncoderID}}`, 10, 64)
	Base58EncoderID, _  = strconv.ParseUint(`.Encoders.Base58EncoderID}}`, 10, 64)
	Base64EncoderID, _  = strconv.ParseUint(`{{.Encoders.Base64EncoderID}}`, 10, 64)
	EnglishEncoderID, _ = strconv.ParseUint(`{{.Encoders.EnglishEncoderID}}`, 10, 64)
	GzipEncoderID, _    = strconv.ParseUint(`{{.Encoders.GzipEncoderID}}`, 10, 64)
	HexEncoderID, _     = strconv.ParseUint(`{{.Encoders.HexEncoderID}}`, 10, 64)
	PNGEncoderID, _     = strconv.ParseUint(`{{.Encoders.PNGEncoderID}}`, 10, 64)
)
View Source
var (
	Base64  = Base64Encoder{}
	Base58  = Base58Encoder{}
	Base32  = Base32Encoder{}
	Hex     = HexEncoder{}
	English = EnglishEncoder{}
	Gzip    = GzipEncoder{}
	PNG     = PNGEncoder{}

	// {{if .Config.Debug}}
	Nop = NoEncoder{}
)
View Source
var EncoderMap = map[uint64]Encoder{}

EncoderMap - Maps EncoderIDs to Encoders

EncoderMap - Maps EncoderIDs to Encoders

Functions

func B58Decode

func B58Decode(b string) []byte

B58Decode decodes a modified base58 string to a byte slice.

func B58Encode

func B58Encode(b []byte) string

B58Encode encodes a byte slice to a modified base58 string.

Types

type Base32Encoder

type Base32Encoder struct{}

Base32Encoder Encoder

func (Base32Encoder) Decode

func (e Base32Encoder) Decode(data []byte) ([]byte, error)

Decode - Base32 Decode

func (Base32Encoder) Encode

func (e Base32Encoder) Encode(data []byte) ([]byte, error)

Encode - Base32 Encode

type Base58Encoder

type Base58Encoder struct{}

Base58 Encoder

func (Base58Encoder) Decode

func (e Base58Encoder) Decode(data []byte) ([]byte, error)

Decode - Base58 Decode

func (Base58Encoder) Encode

func (e Base58Encoder) Encode(data []byte) ([]byte, error)

Encode - Base58 Encode

type Base64Encoder

type Base64Encoder struct{}

Base64Encoder Encoder

func (Base64Encoder) Decode

func (e Base64Encoder) Decode(data []byte) ([]byte, error)

Decode - Base64 Decode

func (Base64Encoder) Encode

func (e Base64Encoder) Encode(data []byte) ([]byte, error)

Encode - Base64 Encode

type Encoder

type Encoder interface {
	Encode([]byte) ([]byte, error)
	Decode([]byte) ([]byte, error)
}

Encoder - Can lossless-ly encode arbitrary binary data

func EncoderFromNonce

func EncoderFromNonce(nonce uint64) (uint64, Encoder, error)

EncoderFromNonce - Convert a nonce into an encoder

func RandomEncoder

func RandomEncoder(size int) (uint64, Encoder)

RandomEncoder - Get a random nonce identifier and a matching encoder

type EnglishEncoder

type EnglishEncoder struct{}

English Encoder - An ASCIIEncoder for binary to english text

func (EnglishEncoder) Decode

func (e EnglishEncoder) Decode(words []byte) ([]byte, error)

Decode - English => Binary

func (EnglishEncoder) Encode

func (e EnglishEncoder) Encode(data []byte) ([]byte, error)

Encode - Binary => English

type GzipEncoder

type GzipEncoder struct{}

Gzip - Gzip compression encoder

func (GzipEncoder) Decode

func (g GzipEncoder) Decode(data []byte) ([]byte, error)

Decode - Uncompressed data with gzip

func (GzipEncoder) Encode

func (g GzipEncoder) Encode(data []byte) ([]byte, error)

Encode - Compress data with gzip

type HexEncoder

type HexEncoder struct{}

Hex Encoder

func (HexEncoder) Decode

func (e HexEncoder) Decode(data []byte) ([]byte, error)

Decode - Hex Decode

func (HexEncoder) Encode

func (e HexEncoder) Encode(data []byte) ([]byte, error)

Encode - Hex Encode

type NoEncoder

type NoEncoder struct{}

NoEncoder - A NOP encoder

func (NoEncoder) Decode

func (n NoEncoder) Decode(data []byte) ([]byte, error)

Decode - Don't do anything

func (NoEncoder) Encode

func (n NoEncoder) Encode(data []byte) ([]byte, error)

Encode - Don't do anything

type PNGEncoder

type PNGEncoder struct{}

PNGEncoder - PNG image object

func (PNGEncoder) Decode

func (p PNGEncoder) Decode(data []byte) ([]byte, error)

Decode reads a encoded PNG to get the original binary data

func (PNGEncoder) Encode

func (p PNGEncoder) Encode(data []byte) ([]byte, error)

Encode outputs a valid PNG file

Directories

Path Synopsis
Package basex provides fast base encoding / decoding of any given alphabet using bitcoin style leading zero compression.
Package basex provides fast base encoding / decoding of any given alphabet using bitcoin style leading zero compression.

Jump to

Keyboard shortcuts

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