Simple text encryption


#1

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();
    }

#2

Turns out all I need is in the Juce demo. I’d be lying if I said this is the first time this has happened!


#3

Just linking this relevant thread: BlowFish String Encryption