encoding

package
v0.0.78 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KindHex encoding value.
	KindHex = "hex/plain"
	// KindHex0XPrefix encoding value.
	KindHex0XPrefix = "hex/0x-prefix"
	// KindBase32 encoding value.
	KindBase32 = "base32/plain"
	// KindBase58 encoding value.
	KindBase58 = "base58/plain"
	// KindBase58SubstrateAddress encoding value.
	KindBase58SubstrateAddress = "base58/ss58-address"
	// KindMnemonicAlgorand encoding value.
	KindMnemonicAlgorand = "mnemonic/algorand"
)

Variables

This section is empty.

Functions

func DataPrefix

func DataPrefix() []byte

DataPrefix used to identify Mailchain messages.

func Decode added in v0.0.70

func Decode(encoding, src string) ([]byte, error)

Decode returns the bytes represented by the decoded string src.

Decode uses the decode method mapped to kind parameter. If the input is kind is unknown or the input is malformed for the decode method it returns an error.

func DecodeBase32 added in v0.0.70

func DecodeBase32(src string) ([]byte, error)

DecodeBase32 returns the bytes represented by the base32 string src.

DecodeBase32 expects that src contains only base32 characters. If the input is malformed, DecodeBase32 returns an error.

func DecodeBase58

func DecodeBase58(src string) ([]byte, error)

DecodeBase58 returns the bytes represented by the base58 string src.

DecodeBase58 expects that src contains only base58 characters. If the input is malformed, DecodeBase58 returns an error.

func DecodeHex

func DecodeHex(s string) ([]byte, error)

DecodeHex returns the bytes represented by the hexadecimal string s.

DecodeHex expects that src contains only hexadecimal characters and that src has even length. If the input is malformed, DecodeString returns the bytes decoded before the error.

func DecodeHexZeroX

func DecodeHexZeroX(in string) ([]byte, error)

DecodeHexZeroX returns the bytes represented by the hexadecimal string src.

DecodeHexZeroX expects that src contains only hex characters and must contain a `0x` prefix. If the input is malformed, DecodeHexZeroX returns an error.

func DecodeMnemonicAlgorand added in v0.0.70

func DecodeMnemonicAlgorand(src string) ([]byte, error)

DecodeMnemonicAlgorand returns the bytes represented by the word list as specified by BIP39 as per the algorand implementation.

DecodeMnemonicAlgorand expects that src contain exactly 25 words, all words MUST be in BIP39 word list and are space delimeted. If the input is malformed, DecodeMnemonicAlgorand returns an error.

func EncodeBase32 added in v0.0.70

func EncodeBase32(src []byte) string

EncodeBase32 returns the string represented by the base32 byte src.

EncodeBase32 expects that src contains only base32 byte. If the input is malformed, EncodeBase32 returns an error.

func EncodeBase58

func EncodeBase58(src []byte) string

EncodeBase58 returns the string represented by the base58 byte src.

EncodeBase58 expects that src contains only base58 byte. If the input is malformed, EncodeBase58 returns an error.

func EncodeHex

func EncodeHex(src []byte) string

EncodeHex returns the hexadecimal encoding of src.

func EncodeHexZeroX

func EncodeHexZeroX(src []byte) (encoded string)

EncodeHexZeroX encodes src into "0x"+hex.Encode. As a convenience, it returns the encoding type used, but this value is always TypeHex0XPrefix. EncodeHexZeroX uses hexadecimal encoding prefixed with "0x".

func EncodeMnemonicAlgorand added in v0.0.70

func EncodeMnemonicAlgorand(src []byte) (string, error)

EncodeMnemonicAlgorand returns the string represented as BIP39 word list as per the Algorand implementation.

EncodeMnemonicAlgorand expects that src contains only base58 byte. If the input is malformed, EncodeBase58 returns an error.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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