I have a scenario where the I get a Base64 (64 bit encoded) string. My requirement is to convert this string to gmp integer (mpz_t).
But according to GMP manual only “The base may vary from 2 to 62” for the function mpz_set_str() .
Is there any approach I can follow to perform a successful conversion?
One idea that struck me was to convert the Base64 to binary and then set the mpz_t variable using mpz_set_str with base 2.
Help would be really appreciated. Thanks.
GMP bases are not the same thing as base64 encoding. You’re on the right track – apply the base64 decode, then use
mpz_importon the result.