-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (30 loc) · 880 Bytes
/
Copy pathmain.go
File metadata and controls
39 lines (30 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"encoding/hex"
"fmt"
"os"
"flag"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/crypto"
)
// REPLACE THIS STRING WITH YOUR PRIVATE KEY
// var PRIVKEY = "REPLACE THIS STR WITH YOUR PRIVATE KEY"
// passphrase to decrypt your key
// if you plan to import privkey to a binary 8+ lenght pwd required
// var PASSWORD = "12345678"
func main() {
pk := flag.String("pk", " ", "hex private key 64 chars")
password := flag.String("password", "12345678", "")
flag.Parse()
privKeyBytes, err := hex.DecodeString(*pk)
if err != nil {
fmt.Println("Error decoding hex private key:", err)
os.Exit(1)
}
privKey := &secp256k1.PrivKey{
Key: privKeyBytes,
}
armoredString := crypto.EncryptArmorPrivKey(privKey, *password, "secp256k1")
// fmt.Println("Armored Private Key:\n")
fmt.Println(armoredString)
}