Add missing keygen.c

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2018-02-11 19:56:05 +00:00
parent 29297ff210
commit 5b929a90b9

22
src/keygen.c Normal file
View File

@@ -0,0 +1,22 @@
#include "common.h"
#include <sodium.h>
#include <stdio.h>
int
gt_keygen(int argc, char **argv)
{
if (sodium_init() == -1) {
gt_log("sodium init failed\n");
return 1;
}
unsigned char key[32];
randombytes_buf(key, sizeof(key));
char buf[2 * sizeof(key) + 1];
gt_tohex(buf, sizeof(buf), key, sizeof(key));
printf("%s\n", buf);
return 0;
}