Simple text encryption

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

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!

1 Like

Just linking this relevant thread: BlowFish String Encryption

1 Like