I’m trying to encrypt a text file using the following code. It works fine, most of the time, but on certain files it just goes into an endless loop of sorts in the BigInteger methods. Could there be certain characters in the text file messing things up?
RSAKey publicKey ...
MemoryBlock mb (fileText.toUTF8().getAddress(), fileText.toUTF8().sizeInBytes());
BigInteger bigInteger;
bigInteger.loadFromMemoryBlock (mb);
if (!bigInteger.isZero())
{
// Encode
BigInteger encodedInteger (bigInteger);
publicKey.applyToValue (encodedInteger);
MemoryBlock encodedMemoryBlock = encodedInteger.toMemoryBlock();
const String newString = encodedMemoryBlock.toBase64Encoding();
}