Created
June 17, 2017 10:23
-
-
Save lzjluzijie/71227650f7f6d60be87e434209298d8a to your computer and use it in GitHub Desktop.
Generate bitcoin private key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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