ah, ok. that makes sense.
I am working on porting a JavaScript library that handles parsing and loading PEM files (think RSA keys).
they do stuff like this in it:
var msg = {
type: type,
procType: null,
contentDomain: null,
dekInfo: null,
headers: [],
body: forge.util.decode64(match[3])
};
I’ve been storing that body as a MemoryBlock wrapped in a var inside of a DynamicObject.
They use the ‘ByteStringBuffer’ class which stores bytes in a stringified format, using UTF16 encoding.
it’s annoying to port over, but I’m getting through it.
If you’re curious, it’s here:
It’s a partial port of this framework, which is a fork of this: GitHub - digitalbazaar/forge: A native implementation of TLS in Javascript and tools to write crypto-based and network-heavy webapps
the CPP equivalent of that JS looks like this:
//remove all \r\n from msg.body
auto base64Text = regexMatch[3];
base64Text = base64Text.removeCharacters("\r\n");
#if false
DBG( base64Text.length() );
#endif
using NV = juce::NamedValueSet::NamedValue;
juce::MemoryBlock bodyBlock;
{
juce::MemoryOutputStream mos(bodyBlock, false);
bool successfulConversion = juce::Base64::convertFromBase64(mos, base64Text);
if(! successfulConversion )
{
jassertfalse;
}
}
juce::NamedValueSet msg
{
NV("type", type),
NV("procType", {}), //empty juce::var
NV("contentDomain", {}),
NV("dekInfo", {}),
NV("headers", juce::Array<juce::var>()),
NV("body", bodyBlock)
};