Is there efficient FREE way yo encode / encrypt the resource files ? ( like unity) 3 questions already asked and haven't been answered

Hello all
Before i start to do it , is there any way or ant body already did it .
i want to encrypt the resources in the game in efficient way the purpose
the resources have copyrights so when you download APK you won’t be able to see them .

The question have bean asked :
How to encrypt Resources in Cocos-JS [ paid solution ]
Resources encryption
How to Encrypt/Descrypt Xml files?

hideho
not sure if this is helpful since I have yet to flesh out my demo before i’ll get to savestates and encryption etc but I remember a teacher saying a lot of algorithms either lost their patent protection or were never patented to begin with as seen in this link:

“Neither DES, AES, Blowfish or Twofish is patented. An example of
patented symmetric encryption system is IDEA (US patent will expire in
2012). The RSA algorithm (asymmetric encryption and digital signatures)
was patented, but the patent expired ten years ago. Basically, if a
cryptographic algorithm is made available through an already installed
Java VM, then it probably is not patented (anymore, or at all).”

does this help you in any way?

cheers

Hey thanks,
im just looking for open source and efficient way to do it , i know DES very well but im not sure it is efficient for resources , it is great for text .
how do other do it ?
i know some games ( not mobile ) encrypt it to some kind of *.bin file .
also how do the AppStore fill about it ?
How do unity do it ?

Someone tried to work with :
https://www.cryptopp.com/

I did this in Cocos2D-ObjC using some simple self-built utilities to pre-process (compress, encrypt, checksum) image and other assets during the build process. There was no support for encrypted resources in the engine so I had to add my own patches for decryption hooks.

I haven’t looked at it in C2DX but I think it is likely you will need to add similar patches.

FWIW I used XXTEA as the base algorithm as it is fast, free and has a small, standalone implementation that’s trivial to incorporate into your code. As algorithms go it’s not massively secure, but it will suffice for protecting game resources.

1 Like

I think im going to take different rout and XOR-ing the data

Fair enough. FWIW XOR isn’t so hard to crack, but it’ll probably be enough to deter casual snoopers.

You’ll still need to patch C2DX if you want to encrypt textures etc. though, and once you’ve done that it really wouldn’t be much work at all to drop in a much better stream cipher like ChaCha20 or something.

But whatever works for you :smile:

I think not the crypt-decrypt is the problem. The problem: how to load the decrypted assets from memory, from some stream.
Rendered textures: are used to be loaded from file or other IO streams.
(http://www.cocos2d-x.org/wiki/Render_To_Texture)
By Music?
And of course you need extra memory and time to decrypt.

I use openssl’ AES to encrypt/decrypt all assets in cocos2dx: https://github.com/halx99/cocos2d-x-pc-port/tree/master/crypto-support

@halx99
this is also good idea
can you share your process and the performance?

It’s so easy for latest cocos2d-x version to do this, you can only hook FileUtils::getContents to decrypt asset
you can use batch encrypt tool to encrypt all assets you want, it’s integrated at: #x-studio365, a game development tool based on Cocos2d-x

performance:

Recently, I also make the cpp-empty-test project support load encrypted assets: https://github.com/halx99/cocos2d-x/tree/v3/tests/cpp-empty-test/Classes
It’s simplely affect everythings, texture files, script files, .csb files, etc…
This maybe a great full assets encrypt/decrypt solution.:slight_smile:

1 Like