Documentation ¶
Overview ¶
Go implementation of the mneumonic library - https://github.com/ggozad/mnemonic.js
Usage: import "github.com/vennd/mneumonic"
// Generate a new mneumonic m := mneumonic.GenerateRandom(128) w := m.toWords() h := m.toHex()
// Recover the hexstring from a mneumonic wordArray := strings.Split("dig direction boyfriend imagine remove shown look two choose sorrow cheat close", " ") m := mneumonic.FromWords(wordArray) h := m.toHex()
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Wc = 1626
View Source
var Words = []string{} /* 1626 elements not displayed */
Functions ¶
This section is empty.
Types ¶
type Mneumonic ¶
type Mneumonic []uint32
func FromHexstring ¶
func FromWords ¶
// Reconstruct from words
i = 0; n = Mnemonic.wc; l = args.length / 3; this.random = new Uint32Array(l); for (; i < l; i++) { w1 = Mnemonic.words.indexOf(args[3 * i]); w2 = Mnemonic.words.indexOf(args[3 * i + 1]); w3 = Mnemonic.words.indexOf(args[3 * i + 2]); this.random[i] = w1 + n * Mnemonic._mod(w2 - w1, n) + n * n * Mnemonic._mod(w3 - w2, n); }
func GenerateRandom ¶
func (Mneumonic) ToHex ¶
Mnemonic.prototype.toHex = function () { var l = this.random.length, res = '', i = 0; for (; i < l; i++) { res += ('00000000' + this.random[i].toString(16)).substr(-8); } return res; };
func (Mneumonic) ToWords ¶
Mnemonic.prototype.toWords = function () { var i = 0, l = this.random.length, n = Mnemonic.wc, words = [], x, w1, w2, w3; for (; i < l; i++) { x = this.random[i]; w1 = x % n; w2 = (((x / n) >> 0) + w1 ) % n; w3 = (((((x / n) >> 0) / n ) >> 0) + w2 ) % n; words.push(Mnemonic.words[w1]); words.push(Mnemonic.words[w2]); words.push(Mnemonic.words[w3]); } return words; };strconv.ParseUint(stringChunk, 10, 32)
Click to show internal directories.
Click to hide internal directories.