Skip to content

Instantly share code, notes, and snippets.

@lzjluzijie
Created June 17, 2017 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lzjluzijie/71227650f7f6d60be87e434209298d8a to your computer and use it in GitHub Desktop.
Save lzjluzijie/71227650f7f6d60be87e434209298d8a to your computer and use it in GitHub Desktop.
Generate bitcoin private key
package main
import (
"crypto/sha256"
"fmt"
base58 "github.com/jbenet/go-base58"
)
func main() {
//以任意字符串作为种子生成私钥
seed := []byte("halu.lu")
privateKey := sha256.Sum256(seed)
fmt.Printf("Your hex private key is : %x\n", privateKey)
wifKeyBytes := append([]byte{0x80}, privateKey[:]...)
hash1 := sha256.Sum256(wifKeyBytes)
hash2 := sha256.Sum256(hash1[:])
wifKeyBytes = append(wifKeyBytes, hash2[:4]...)
wifKey := base58.Encode(wifKeyBytes)
fmt.Printf("Your wif private key is : %s\n", wifKey)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment