Assets protection / encryption


I would like to encrypt or package my assets for windows target so that the user wont be able to use them. I have tried embedding but this feature seems to have a size limit and at a certain point it throws me a “Buffer.add: could not grow buffer” error when building. Is there any way to encrypt the assets?


Sure, you could load a ByteArray and use any mechanism you want to unpack/decrypt them. I’d like to see something like this available directly from the command-line tools (ways to push multiple assets into asset packs, and optionally add obfuscation) but this would require some work

1 Like

Thanks. Is the command-line packaging tool already in the road map? And also is there a way to get around the “could not grow buffer” error?

That error comes from Haxe resources, Haxe 3.2 increases this limit, I believe. We already have command-line tools (obviously :slight_smile: ) but this would be an improvement to the existing asset system

Alright, I ll use Assets.get…() for now, Also I believe there is a library that uses ByteArray to serialize bitmap data assets etc, but I think its outdated. Hope the new asset system comes out soon

In one application (not for Haxe …), I simply used a “running-XOR” obfuscation algorithm that ran in-place, using two randomly-chosen constant bytes as input. As long as you make it “not trivially-easy to do,” that’s a good-enough lock “to keep the honest people out.” :slight_smile:

Happy to include a pull request if you have a simple way of integrating special asset formats into the tool output + the DefaultAssetLibrary class to unpack them :slight_smile: