I’m trying to write code to encrypt/decrypt strings in a cross-platform way, basically so a Python-based server can send encrypted messages which are decrypted in a JUCE-based plugin, by base-64 encoding those strings and then applying RSA-encryption. I am having trouble simply encoding a string into a MemoryBlock and getting the original string back out. It seems that everything would work if there was a corresponding Base64::fromBase64 function, but there isn’t. My code so far:
String original = "Hello I am Example Text.";
String base64String = Base64::toBase64(original);
MemoryOutputStream inputStream;
Base64::convertFromBase64(static_cast<OutputStream&>(inputStream), base64String);
//For later:
//applyRSA(inputStream.getMemoryBlock(), key)
MemoryOutputStream outputStream;
Base64::convertToBase64(outputStream, inputStream.getData(), inputStream.getDataSize());
String recovered = outputStream.toString()
The value of recovered is the same as base64String - is there a way to effectively reverse the Base64::toBase64 function and recover the original String?
Also open to suggestions if I’m way off-base - I thought this would be easier so maybe I’m on the wrong path.