Beispiel #1
0
// Uncompressed private key
func sec2b58unc(pk []byte) string {
	var dat [37]byte
	dat[0] = privver
	copy(dat[1:33], pk)
	sh := btc.Sha2Sum(dat[0:33])
	copy(dat[33:37], sh[:4])
	return btc.Encodeb58(dat[:])
}
Beispiel #2
0
// Compressed private key
func sec2b58com(pk []byte) string {
	var dat [38]byte
	dat[0] = privver
	copy(dat[1:33], pk)
	dat[33] = 1 // compressed
	sh := btc.Sha2Sum(dat[0:34])
	copy(dat[34:38], sh[:4])
	return btc.Encodeb58(dat[:])
}
Beispiel #3
0
func main() {
	flag.Parse()
	if *help {
		flag.PrintDefaults()
		return
	}

	msg, _ := ioutil.ReadAll(os.Stdin)
	if len(msg) == 0 {
		return
	}

	if *decode {
		res := btc.Decodeb58(strings.Trim(string(msg), " \t\n\r"))
		if *binary {
			os.Stdout.Write(res)
		} else {
			fmt.Println(hex.EncodeToString(res))
		}
	} else {
		fmt.Println(btc.Encodeb58(msg))
	}
}