b1t6

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: MIT Imports: 6 Imported by: 14

Documentation

Overview

Package b1t6 implements the b1t6 encoding encoding which uses a group of 6 trits to encode each byte. See the IOTA protocol RFC-0015 for details.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidLength reports an attempt to decode an input which has a trit-length that is not a multiple of 6.
	ErrInvalidLength = errors.New("length must be a multiple of 6 trits")
	// ErrInvalidTrits reports an attempt to decode an input that contains an invalid trit sequence.
	ErrInvalidTrits = errors.New("invalid trits")
)

Functions

func Decode

func Decode(dst []byte, src trinary.Trits) (int, error)

Decode decodes src into DecodedLen(len(in)) bytes of dst and returns the actual number of bytes written. Decode expects that src contains a valid b1t6 encoding and that src has a length that is a multiple of 6, it returns an error otherwise. If src does not contain trits, the behavior of Decode is undefined.

func DecodeTrytes

func DecodeTrytes(src trinary.Trytes) ([]byte, error)

DecodeTrytes returns the bytes represented by the t6b1 encoded trytes. DecodeTrytes expects that src contains a valid b1t6 encoding and that in has even length, it returns an error otherwise. If src does not contain trytes, the behavior of DecodeTrytes is undefined.

func DecodedLen

func DecodedLen(n int) int

DecodedLen returns the byte-length of a decoding of n source trits.

func Encode

func Encode(dst trinary.Trits, src []byte) int

Encode encodes src into EncodedLen(len(in)) trits of dst. As a convenience, it returns the number of trits written, but this value is always EncodedLen(len(src)). Encode implements the b1t6 encoding converting a bit string into ternary.

func EncodeToTrytes

func EncodeToTrytes(src []byte) trinary.Trytes

EncodeToTrytes returns the encoding of src converted into trytes.

func EncodedLen

func EncodedLen(n int) int

EncodedLen returns the trit-length of an encoding of n source bytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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