-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgenkey.js
30 lines (22 loc) · 957 Bytes
/
genkey.js
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
var eos = require("eosjs-ecc");
var fs = require("fs");
eos.PrivateKey.randomKey()
.then(privateKey => {
if (process.argv.length > 2 && process.argv[2] == "client"){
var privateKey = privateKey.toWif();
var publicKey = eos.PrivateKey.fromWif(privateKey).toPublic().toString();
console.log("privateKey (use on client to make authorized api calls to server)");
console.log(" ", privateKey);
console.log(" ");
console.log("publicKey (use on server to accept authorized api calls to server)");
console.log(" ", eos.PrivateKey.fromWif(privateKey).toPublic().toString());
console.log(" ");
fs.writeFileSync("./config/client.json", JSON.stringify({"private_key": privateKey}, null, 2));
console.log("Client application configured with private key.");
}
else {
console.log("privateKey", privateKey.toWif());
console.log("publicKey", eos.PrivateKey.fromWif(privateKey.toWif()).toPublic().toString());
}
}
)