I'm trying to write helper functions for a program I'm making and I need to return the keys as strings. Found a way to convert the RSA keys from PrivateKey/PublicKey to Base64 string.
int main()
{
//Generate params
AutoSeededRandomPool rng;
InvertibleRSAFunction params;
params.Initialize(rng, 4096);
//Generate Keys
RSA::PrivateKey privKey(params);
RSA::PublicKey pubKey(params);
//Encode keys to Base64
string encodedPriv, encodedPub;
Base64Encoder privKeySink(new StringSink(encodedPriv));
privKey.DEREncode(privKeySink);
Base64Encoder pubKeySink(new StringSink(encodedPub));
privKey.DEREncode(pubKeySink);
RSA::PrivateKey pvKeyDecoded;
RSA::PublicKey pbKeyDecoded;
//how to decode...
system("pause");
return 0;
}
Now, how do I load the encoded keys back? I wasn't able to find any information on that.