mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Implemented config and crypto infrastructure (#2)
Added config file read/write infrastructure with RapidJSON. Added key pair generation and sign/verify helper with libsodium.
This commit is contained in:
24
src/main.cpp
24
src/main.cpp
@@ -4,11 +4,31 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include "conf.h"
|
||||
#include "crypto.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (!conf::init() || !crypto::init())
|
||||
{
|
||||
cerr << "Init error\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Example sign and verification.
|
||||
unsigned char msg[10] = "hotpocket";
|
||||
unsigned char *sig = new unsigned char[crypto::get_sig_len()];
|
||||
crypto::sign(msg, 10, sig);
|
||||
|
||||
bool isValid = crypto::verify(msg, 10, sig);
|
||||
if (isValid)
|
||||
cout << "Signature verified.\n";
|
||||
else
|
||||
cout << "Invalid signature.\n";
|
||||
|
||||
cout << "exited normally\n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user