Browse Source

add package godoc and examples

pull/23/head
Glen De Cauwsemaecker 3 years ago
committed by Tyler Smith
parent
commit
052384f652
No known key found for this signature in database GPG Key ID: CA38F1A9BE0EC890
2 changed files with 32 additions and 0 deletions
  1. +4
    -0
      bip39.go
  2. +28
    -0
      example_test.go

+ 4
- 0
bip39.go View File

@ -1,3 +1,7 @@
// Package bip39 is the official Golang implementation of the BIP39 spec.
//
// The official BIP39 spec can be found at
// https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
package bip39
import (

+ 28
- 0
example_test.go View File

@ -0,0 +1,28 @@
package bip39_test
import (
"encoding/hex"
"fmt"
"github.com/tyler-smith/go-bip39"
)
func ExampleNewMnemonic() {
// the entropy can be any byte slice, generated how pleased,
// as long its bit size is a multiple of 32 and is within
// the inclusive range of {128,256}
entropy, _ := hex.DecodeString("066dca1a2bb7e8a1db2832148ce9933eea0f3ac9548d793112d9a95c9407efad")
// generate a mnemomic
mnemomic, _ := bip39.NewMnemonic(entropy)
fmt.Println(mnemomic)
// output:
// all hour make first leader extend hole alien behind guard gospel lava path output census museum junior mass reopen famous sing advance salt reform
}
func ExampleNewSeed() {
seed := bip39.NewSeed("all hour make first leader extend hole alien behind guard gospel lava path output census museum junior mass reopen famous sing advance salt reform", "TREZOR")
fmt.Println(hex.EncodeToString(seed))
// output:
// 26e975ec644423f4a4c4f4215ef09b4bd7ef924e85d1d17c4cf3f136c2863cf6df0a475045652c57eb5fb41513ca2a2d67722b77e954b4b3fc11f7590449191d
}

Loading…
Cancel
Save