Hello. I have a MemoryBlock encrypting and decrypting successfully. However, the in-between stage of writing to and loading from a file is somehow changing the MemoryBlock so it’s not decrypting properly. I’m using the same BlowFish for both e&d so it’s not that. Code:
MemoryBlock mb = MemoryBlock(); ScopedPointer <MemoryOutputStream> mos = new MemoryOutputStream (mb, false); vt.writeToStream (*mos); mos->flush(); const String newKey = key + "_" + OnlineUnlockStatus::MachineIDUtilities::getLocalMachineIDs()  + "_" + name + "_" + email + "_" + expiry; BlowFish blowFish = BlowFish (&newKey, static_cast <int> (newKey.getNumBytesAsUTF8())); blowFish.encrypt (mb); File file = File::getSpecialLocation (File::userDesktopDirectory).getChildFile ("testFile"); file.create(); FileOutputStream fos (file); fos.write (&mb, mb.getSize()); fos.flush(); File file2 = File::getSpecialLocation (File::userDesktopDirectory).getChildFile ("testFile"); ScopedPointer <FileInputStream> fis = new FileInputStream (file2); MemoryBlock mb2 = MemoryBlock(); file2.loadFileAsData (mb2); //MemoryBlock mb2 = MemoryBlock (mb); PROOF blowFish.decrypt (mb2);
I’ve also tested The sizes of of all the files / MemoryBlocks and they correlate. The proof is that the same MemoryBlock decrypts successfully if not written to a file, so it’s something about the way the MemoryBlock is written / read.