Add gen-key for shared secret key generation
This commit is contained in:
27
gen-key.cc
Normal file
27
gen-key.cc
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <ctime>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "crypto.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 2) {
|
||||
std::cerr << "Usage: " << argv[0] << " key_filename" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string key;
|
||||
CryptoBase::GenKey(&key);
|
||||
|
||||
{
|
||||
std::fstream key_file(argv[1], std::fstream::out);
|
||||
if (key_file.fail()) {
|
||||
std::cerr << "Failed to open key file" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
key_file << "# Shared secret key" << std::endl;
|
||||
key_file << CryptoBase::BinToHex(key) << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user