Created
May 12, 2017 18:05
-
-
Save ukaszjankowski/fe7856f824314d12abb064c5f7a1000a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <gmp.h> | |
#include <cstdio> | |
int main(int argc, char *argv[]) | |
{ | |
mpz_t a, b, c, d; | |
char n1[] = "286727957567469097160964321636541616262120875018486518431323373373323997065608342"; | |
char n2[] = "124090546721983757834918239836534598129831236591283865182359664109783723654812937"; | |
mpz_init_set_str (a, n1, 10); | |
mpz_init_set_str (b, n2, 10); | |
mpz_init_set_str (c, "0", 10); | |
mpz_init_set_str (d, "1337", 10); | |
mpz_add (c, a, b); // c = n1 + n2 | |
mpz_mul (c, c, d); // c= c * 1337 | |
char *result = mpz_get_str(NULL, 16, c); | |
char bytearray[30] = {0}; | |
char str_len = strlen(result); | |
for (size_t i = 0; i < (str_len / 2); i++) { | |
sscanf(result + 2*i, "%02x", &bytearray[i]); | |
putc(bytearray[i], stdout); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment