1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-06-28 18:03:36 +00:00
codecrypt/doc/nums/hexsqrt.c
Mirek Kratochvil 3659cc837e xsynd: new stream cipher
This one is especially cool. It is code based (yeyeye matches the
project name! :D ), it is provably secure (not like the others!) AAAND
is still quite fast (not fast as chacha though).
2014-04-02 10:49:55 +02:00

29 lines
470 B
C

#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
int main (int argc, char**argv)
{
int param;
char *output;
mp_exp_t exp;
mpf_t sqrt;
if (argc < 2 ||
1 != sscanf (argv[1], "%d", &param) ||
param < 2) return 1;
mpf_set_default_prec (100000);
mpf_init (sqrt);
mpf_sqrt_ui (sqrt, param);
output = mpf_get_str (NULL, &exp, 16, 0, sqrt);
printf ("%.*s.%s\n", (int) exp, output, output + exp);
free (output);
mpf_clear (sqrt);
return 0;
}