Files
funstraw/gen-keypair.cc

36 lines
768 B
C++
Raw Normal View History

2015-02-05 12:55:48 +00:00
#include <ctime>
#include <fstream>
#include <iostream>
#include "crypto.h"
int main(int argc, char *argv[]) {
if (argc < 3) {
2015-02-05 13:04:36 +00:00
std::cerr << "Usage: " << argv[0] << " secret_key_filename public_key_filename" << std::endl;
2015-02-05 12:55:48 +00:00
return 1;
}
2015-02-05 13:04:36 +00:00
std::string secret_key, public_key;
CryptoBase::GenKeyPair(&secret_key, &public_key);
2015-02-05 12:55:48 +00:00
{
2015-02-05 13:04:36 +00:00
std::fstream secret_key_file(argv[1], std::fstream::out);
if (secret_key_file.fail()) {
2015-02-05 12:55:48 +00:00
std::cerr << "Failed to open secret key file" << std::endl;
return 1;
}
secret_key_file << secret_key;
2015-02-05 12:55:48 +00:00
}
{
2015-02-05 13:04:36 +00:00
std::fstream public_key_file(argv[2], std::fstream::out);
if (public_key_file.fail()) {
2015-02-05 12:55:48 +00:00
std::cerr << "Failed to open public key file" << std::endl;
return 1;
}
public_key_file << public_key;
2015-02-05 12:55:48 +00:00
}
return 0;
}