mirror of
https://github.com/PurpleI2P/i2pd-tools.git
synced 2025-05-01 13:12:30 +02:00
keygen added
This commit is contained in:
parent
85f4485214
commit
18f7221980
3 changed files with 89 additions and 0 deletions
34
keygen.cpp
Normal file
34
keygen.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <stdlib.h>
|
||||
#include "Crypto.h"
|
||||
#include "Identity.h"
|
||||
|
||||
int main (int argc, char * argv[])
|
||||
{
|
||||
if (argc < 3)
|
||||
{
|
||||
std::cout << "Usage: keygen filename <signuture type>" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
i2p::crypto::InitCrypto (false);
|
||||
i2p::data::SigningKeyType type = i2p::data::SIGNING_KEY_TYPE_DSA_SHA1;
|
||||
if (argc >= 3) type = atoi (argv[2]);
|
||||
auto keys = i2p::data::PrivateKeys::CreateRandomKeys (type);
|
||||
std::ofstream f (argv[1], std::ofstream::binary | std::ofstream::out);
|
||||
if (f)
|
||||
{
|
||||
size_t len = keys.GetFullLen ();
|
||||
uint8_t * buf = new uint8_t[len];
|
||||
len = keys.ToBuffer (buf, len);
|
||||
f.write ((char *)buf, len);
|
||||
delete[] buf;
|
||||
std::cout << "Destination " << keys.GetPublic ()->GetIdentHash ().ToBase32 () << " created" << std::endl;
|
||||
}
|
||||
else
|
||||
std::cout << "Can't create file " << argv[1] << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue