Public key generation

This commit is contained in:
Ian Gulliver
2015-02-05 12:55:48 +00:00
parent 99aac0d648
commit d37b9a7e41
5 changed files with 72 additions and 35 deletions

38
gen-keypair.cc Normal file
View File

@@ -0,0 +1,38 @@
#include <ctime>
#include <fstream>
#include <iostream>
#include "crypto.h"
int main(int argc, char *argv[]) {
if (argc < 3) {
std::cerr << "Usage: " << argv[0] << " secret_filename public_filename" << std::endl;
return 1;
}
std::string pk;
std::string sk;
CryptoBase::GenKeyPair(&sk, &pk);
{
std::fstream skf(argv[1], std::fstream::out);
if (skf.fail()) {
std::cerr << "Failed to open secret key file" << std::endl;
return 1;
}
skf << "# Secret key" << std::endl;
skf << CryptoBase::BinToHex(sk) << std::endl;
}
{
std::fstream pkf(argv[2], std::fstream::out);
if (pkf.fail()) {
std::cerr << "Failed to open public key file" << std::endl;
return 1;
}
pkf << "# Public key" << std::endl;
pkf << CryptoBase::BinToHex(pk) << std::endl;
}
return 0;
}