cocos2d/cocos2d-swift — pull request #1109 by slembcke (2014-12-06 07:36:04+00:00)
Title: CCFile

Initial implementation of the CCFile class. The basic functionality and tests were done so quickly that I decided to go ahead and implement gzipped and encrypted streams.

For encryption, I went with the XXTEA algorithm since it was really easy to use. It's not going to be foolproof anyway, so I didn't see much point spending more than a couple hours on it. I made a little command line utility to perform the encryption as well. It's pretty basic. It encrypts 4kb blocks of data at a time, where the first four bytes of each block are the total number of bytes in the block. Files will be rounded up to the next 4kb in size. Right now the key I used for the tests is hardcoded. I figured eventually we'd probably add a SpriteBuilder setting to generate a key for a project and have the user copy paste it into their app delegate. Sort of like TexturePacker did `[CCFile setEncryptionKey:@"0123456789ABCDEF"];`