t5b1

package
v1.0.0-beta.15....-0de5f12 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package t5b1 implements the t5b1 encoding encoding which uses one byte to represent each 5-trit group.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

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

Decode decodes src into DecodedLen(len(src)) trits of dst and returns the actual number of bytes written. Decode expects that src contains a valid t5b1 encoding, it returns an error otherwise.

func DecodeToTrytes

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

DecodeToTrytes returns the trytes represented by the t5b1 encoded bytes. The returned trytes always have a length of Ceil(DecodedLen(len(src))/3). DecodeToTrytes expects that src contains a valid t5b1 encoding of a tryte-string. If the input is malformed or does not contain the correct zero padding, it returns an error.

func DecodedLen

func DecodedLen(n int) int

DecodedLen returns the trit-length of a decoding of n source bytes.

func Encode

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

Encode encodes src into EncodedLen(len(src)) bytes of dst. As a convenience, it returns the number of trits written, but this value is always EncodedLen(len(src)). Encode implements the t5b1 encoding converting a trit string into binary. If the length of src is not a multiple of 5, it is padded with zeroes. If src does not contain trits, the behavior of Encode is undefined.

func EncodeTrytes

func EncodeTrytes(src trinary.Trytes) []byte

EncodeTrytes returns the encoding of src converted into bytes. If the corresponding number of trits of src is not a multiple of 5, it is padded with zeroes. If src does not contain valid trytes, the behavior is undefined.

func EncodedLen

func EncodedLen(n int) int

EncodedLen returns the byte-length of an encoding of n source trits.

Types

This section is empty.

Jump to

Keyboard shortcuts

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