Hehe cool. I opened the png and the zng in notepade and started doing string searches and a lot of png strings showed up in the zng. That's because by loading the entire bank into a string was bogging down the whole xor function so I ended up just encrypting a small part of the start, middle and end of the file. But by doing xor on each bank byte I can compress/encrypt an enormous bank of 32Mb in about 16 sec. Thanks for that suggestion Snark. After I used this method there are no matches at all so the entire contents are scrambled very thoroughly.
So now the flow is read the png into a bank. Compress the bank with zlib, encrypt the bank byte per byte with the 32bit encryption key, then savebank to a zng. That's pretty freakin secure. I also have a LoadImageZNG function that loads the zng into a bank, decrypts it, uncompresses it and returns a LoadImage(bank). I couldn't ask for more.
Oh and the 32Mb file was only 27Mb after being converted to ZNG. :-)
Oh here's the new method with your suggestion:
So now the flow is read the png into a bank. Compress the bank with zlib, encrypt the bank byte per byte with the 32bit encryption key, then savebank to a zng. That's pretty freakin secure. I also have a LoadImageZNG function that loads the zng into a bank, decrypts it, uncompresses it and returns a LoadImage(bank). I couldn't ask for more.
Oh and the 32Mb file was only 27Mb after being converted to ZNG. :-)
Oh here's the new method with your suggestion:
Function XorBank:TBank(bank:TBank, key$) For i = 0 To bank.size()-1 Local c$ = Chr$(PeekByte(bank,i)) PokeByte(bank,i,Asc(XorCrypt(c,key))) Next Return bank End Function Function XorCrypt:String(str$, key$) Local ml%, pl%, i%, result$ ml% = Len(str) pl% = Len(key) For i = 0 Until ml Local c:Byte = str$[i] Local k = key$[i Mod pl] c = c ~ k result$ :+ Chr(c) Next Return result$ EndFunction