words

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const BankSize = 2048

Variables

This section is empty.

Functions

This section is empty.

Types

type CRC16

type CRC16 struct {
	Poly uint16
	// contains filtered or unexported fields
}

CRC16 does the ieee crc16 polynomial check

func NewCCITTCRC16

func NewCCITTCRC16() *CRC16

func NewIBMCRC16

func NewIBMCRC16() *CRC16

func NewSCSICRC16

func NewSCSICRC16() *CRC16

func (*CRC16) AddECC

func (c *CRC16) AddECC(input []byte) []byte

func (*CRC16) CheckECC

func (c *CRC16) CheckECC(input []byte) ([]byte, error)

type CRC32

type CRC32 struct {
	Poly uint32
	// contains filtered or unexported fields
}

CRC32 does the ieee crc32 polynomial check

func NewCastagnoliCRC32

func NewCastagnoliCRC32() *CRC32

func NewIEEECRC32

func NewIEEECRC32() *CRC32

func NewKoopmanCRC32

func NewKoopmanCRC32() *CRC32

func (*CRC32) AddECC

func (c *CRC32) AddECC(input []byte) []byte

func (*CRC32) CheckECC

func (c *CRC32) CheckECC(input []byte) ([]byte, error)

type CRC64

type CRC64 struct {
	Poly uint64
	// contains filtered or unexported fields
}

CRC64 does the ieee crc64 polynomial check

func NewECMACRC64

func NewECMACRC64() *CRC64

func NewISOCRC64

func NewISOCRC64() *CRC64

func (*CRC64) AddECC

func (c *CRC64) AddECC(input []byte) []byte

func (*CRC64) CheckECC

func (c *CRC64) CheckECC(input []byte) ([]byte, error)

type Codec

type Codec interface {
	BytesToWords([]byte) ([]string, error)
	WordsToBytes([]string) ([]byte, error)
}

type ECC

type ECC interface {
	// AddECC calculates an error-correcting code for the input
	// returns an output with the code appended
	AddECC([]byte) []byte

	// CheckECC verifies if the ECC is proper on the input and returns
	// the data with the code removed, or an error
	CheckECC([]byte) ([]byte, error)
}

ECC is used for anything that calculates an error-correcting code

type NoECC

type NoECC struct{}

NoECC is a no-op placeholder, kind of useless... except for tests

func (NoECC) AddECC

func (_ NoECC) AddECC(input []byte) []byte

func (NoECC) CheckECC

func (_ NoECC) CheckECC(input []byte) ([]byte, error)

type WordCodec

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

func LoadCodec

func LoadCodec(bank string) (codec *WordCodec, err error)

LoadCodec loads a pre-compiled language file

func MustLoadCodec

func MustLoadCodec(bank string) *WordCodec

MustLoadCodec panics if word bank is missing, only for tests

func NewCodec

func NewCodec(words []string) (codec *WordCodec, err error)

func (*WordCodec) BytesToWords

func (c *WordCodec) BytesToWords(raw []byte) (words []string, err error)

TODO: add checksum

func (*WordCodec) GetIndex

func (c *WordCodec) GetIndex(word string) (int, error)

GetIndex finds the index of the words to create bytes Generates a map the first time it is loaded, to avoid needless computation when list is not used.

func (*WordCodec) WordsToBytes

func (c *WordCodec) WordsToBytes(words []string) ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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