Protect content in javascript

I would like to transfer one of my games to WebGL, but it uses sounds and images that I licensed from third parties. This is against the license, so that he simply pulls out unprotected files directly from the web server.

Before that, I went around this by putting a bunch of these files into my own file format, but I'm not sure if I can just read the number of bytes from the file in X and then transfer it to Javascript and say “hey, this is a png image”. Is it possible? Are there other ways to protect files?

+3
source share
5 answers

This is the trick:

var i = new Image();
i.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAABJJREFUeJxj+N/wHw9iGJXGhgDu6Pk5cOz+IwAAABF0RVh0Q29tbWVudAB0RVhUIHRleHTAVE3RAAAAAElFTkSuQmCC';

Then, if you insert this line somewhere obscure and scramble it, it should avoid low-hanging fruits.

0
source

, , , . , , , , , . ( : , , , - , , , , .)

+3

JS , JS, , .

- ...

var imageContainer = function(protectedImageContainer) {
        var that = {};
        that.getImage = function () { 
              // bytes -> image transform would happen here.
              return protectedImageContainer.data; 
        };
        return that;
};

protectedImageContainer.data , getImage.

" ..." , .

+1

You cannot protect things in javascript, since they are executed on the client side, and everything you do to confuse or “protect” files can be canceled by a user who is willing to do so.

0
source

Will your license allow you to store resources in an encrypted form on a web server? If this is not an option, you will probably have to use something that can encapsulate media - Java applets, perhaps.

-2
source

All Articles