Laika/tools/genkey/src/main.c

26 lines
627 B
C

#include "core/lerror.h"
#include "core/lsodium.h"
#include <stdio.h>
#include <string.h>
int main(int argv, char **argc)
{
unsigned char priv[crypto_kx_SECRETKEYBYTES], pub[crypto_kx_PUBLICKEYBYTES];
char buf[256];
if (sodium_init() < 0) {
printf("Libsodium failed to init!\n");
return 1;
}
crypto_kx_keypair(pub, priv);
printf("[~] Generated keypair!\n");
sodium_bin2hex(buf, 256, pub, crypto_kx_PUBLICKEYBYTES);
printf("[~] public key: %s\n", buf);
sodium_bin2hex(buf, 256, priv, crypto_kx_SECRETKEYBYTES);
printf("[~] private key: %s\n\n", buf);
return 0;
}