Documentation ¶
Overview ¶
Package mnemonicode …
Index ¶
- Constants
- func DecodeWordList(dst []byte, src []string) (result []byte, err error)
- func EncodeWordList(dst []string, src []byte) (result []string)
- func NewDecodeTransformer() transform.Transformer
- func NewDecodeWriter(w io.Writer) io.WriteCloser
- func NewDecoder(r io.Reader) io.Reader
- func NewEncodeReader(r io.Reader, c *Config) io.Reader
- func NewEncodeTransformer(c *Config) transform.Transformer
- func NewEncoder(w io.Writer, c *Config) io.WriteCloser
- func WordsRequired(length int) int
- type Config
- type UnexpectedEndWordError
- type UnexpectedWordError
- type UnknownWordError
- type WordError
Constants ¶
const WordListVersion = "0.7"
WordListVersion is the version of compiled in word list.
Variables ¶
This section is empty.
Functions ¶
func DecodeWordList ¶
DecodeWordList decodes the mnemonic words in src into bytes which are appended to dst.
func EncodeWordList ¶
EncodeWordList encodes src into mnemomic words which are appended to dst. The final wordlist is returned. There will be WordsRequired(len(src)) words appeneded.
func NewDecodeTransformer ¶
func NewDecodeTransformer() transform.Transformer
NewDecodeTransformer returns a new transform that decodes mnemonic words into the represented bytes. Unrecognized words will trigger an error.
func NewDecodeWriter ¶
func NewDecodeWriter(w io.Writer) io.WriteCloser
NewDecodeWriter returns a new io.WriteCloser that will write decoded bytes from mnemonic words written to it. Unrecognized words will cause a write error. The user needs to call Close to flush unwritten bytes that may be buffered.
func NewDecoder ¶
NewDecoder returns a new io.Reader that will return the decoded bytes from mnemonic words in r. Unrecognized words in r will cause reads to return an error.
func NewEncodeReader ¶
NewEncodeReader returns a new io.Reader that will return a formatted list of mnemonic words representing the bytes in r.
The configuration of the word formatting is controlled by c, which can be nil for default formatting.
func NewEncodeTransformer ¶
func NewEncodeTransformer(c *Config) transform.Transformer
NewEncodeTransformer returns a new transformer that encodes bytes into mnemonic words.
The configuration of the word formatting is controlled by c, which can be nil for default formatting.
func NewEncoder ¶
func NewEncoder(w io.Writer, c *Config) io.WriteCloser
NewEncoder returns a new io.WriteCloser that will write a formatted list of mnemonic words representing the bytes written to w. The user needs to call Close to flush unwritten bytes that may be buffered.
The configuration of the word formatting is controlled by c, which can be nil for default formatting.
func WordsRequired ¶
WordsRequired returns the number of words required to encode input data of length bytes using mnomonic encoding.
Every four bytes of input is encoded into three words. If there is an extra one or two bytes they get an extra one or two words respectively. If there is an extra three bytes, they will be encoded into three words with the last word being one of a small set of very short words (only needed to encode the last 3 bits).
Types ¶
type Config ¶
type Config struct { LinePrefix string LineSuffix string WordSeparator string GroupSeparator string WordsPerGroup uint GroupsPerLine uint WordPadding rune }
A Config structure contains options for mneomonic encoding.
{PREFIX}word{wsep}word{gsep}word{wsep}word{SUFFIX}
type UnexpectedEndWordError ¶
type UnexpectedEndWordError string
func (UnexpectedEndWordError) Error ¶
func (e UnexpectedEndWordError) Error() string
func (UnexpectedEndWordError) Word ¶
func (e UnexpectedEndWordError) Word() string
type UnexpectedWordError ¶
type UnexpectedWordError string
func (UnexpectedWordError) Error ¶
func (e UnexpectedWordError) Error() string
func (UnexpectedWordError) Word ¶
func (e UnexpectedWordError) Word() string
type UnknownWordError ¶
type UnknownWordError string
func (UnknownWordError) Error ¶
func (e UnknownWordError) Error() string
func (UnknownWordError) Word ¶
func (e UnknownWordError) Word() string