How to protect (encrypt) .tmx files (or any other kind of file...)?

Basically what can I do to protect the .tmx files of my game? Is there any example on how I can encrypt/decrypt these files?

Thanks!

I haven’t seen anything to do with encryption in Cocos2d-x v2, but no idea about v3.

If v3 doesn’t have encryption, my guess would be that the best way would be to add an encryption library to your project and whenever you want to use encrypted data:

  1. Use the library to decrypt your file. If the library doesn’t have the functionality to read a file, read the file into memory yourself and then use the library to decrypt the data.
  2. Use the decrypted data with the appropriate Cocos object.

If the Cocos object doesn’t directly accept data, e.g createWithData(void* data), you would have to have to implement that functionality yourself.

I neither have examples or source code for this, nor have I attempted it, but it is how I would attempt this.

I could be way off base here, but, I assume that you cannot put a tmx into TexturePacker, which offers encryption and then pull it out in you code when you are ready for it?