Archived

This topic is now archived and is closed to further replies.

How exactly could I encrypt bitmap files in my game???

This topic is 5008 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

HI, First of, I''m not sure if "encrypt" is the right term to use but here''s what I''m getting into. I have a bitmap folder in my game that contains all things graphical (character/enemy frames, tiles, menus etc.), but the thing is, when I give a copy of it to my friends, I don''t want them to access the bitmap files individually. Is there any way that I can "encrypt" my bitmap files so that accessing them is impossible? THANKS IN ADVANCE!!

Share this post


Link to post
Share on other sites
It is never impossible. However, you can make it difficult by stripping out all the header information and just store the bitmap data. On top of this you could also compress the bitmap by using run-length encoding. It is simple and will throw off any casual attempts. Also change the extension to something of your own invention.



First make it work, then make it fast. --Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

[edited by - CaptainJester on March 23, 2004 5:52:52 AM]

Share this post


Link to post
Share on other sites
Rename the folder they are stored in as ''Sounds'' and change the file extension to ''.wav''. You can also rename your ''Sounds'' folder ''Images'' and change all the sound files to .bmp.

Your loader program will know that the file extensions are switched around, and be able to load them properly. Your friends however, will be baffled that none of the .bmps load properly.

Alternatively, you could include the files in a resource. (either in the main exe or in a resource dll) Unless they have access to a resource editor or are prepared to start messing around with hex editors, the chances are they won''t be able to mess with your files.

Share this post


Link to post
Share on other sites
quote:
Original post by CaptainJester
It is never impossible. However, you can make it difficult by stripping out all the header information and just store the bitmap data. On top of this you could also compress the bitmap by using run-length encoding. It is simple and will throw off any casual attempts. Also change the extension to something of your own invention.



If you''re going to store the image data without image RLE compression, adding a little bit of text like "MYBITMAP" at the start of the file will prevent them from easily being able to load them as a RAW image in Paint Shop Pro.


.:Cubicle2:.

Share this post


Link to post
Share on other sites
If you don''t want to support modding and you want to protect your artwork from being changed/stolen. Although they will eventually be able to rip your graphics and/or change it, encrypting/storing them in 1 huge file is generally a good idea.

Read this article on how to create a PAK file:
http://www.gamedev.net/reference/articles/article1991.asp

Toolmaker



-Earth is 98% full. Please delete anybody you can.

Share this post


Link to post
Share on other sites
I''ve been thinking a similar question, so thanks everyone for replying. As far as WHY someone at this level would want to encode the bitmaps, it''s simple. Modding is great when it''s obvious that people know who did most of the groundwork on the engine, but when you''re starting out, just writing a simple Tetris game is a lot of work to a new person. Imagine how much it would suck if someone downloaded your game that you cut your teeth on, took out your name on the loading screen, changed some graphics around and called it their own? And they could get away with it too because the game is so simple most people wouldn''t question it.

Also, having encoded files looks a bit more professional than just having bitmaps in a folder, as well as using compression allows you to distribute it easier.

In my case, I plan to create a tool to allow someone to mod the graphics and such, but with built in safeguards to still display that I did the underlying work.

Share this post


Link to post
Share on other sites
quote:
Original post by lukeyes
Modding is great when it''s obvious that people know who did most of the groundwork on the engine, but when you''re starting out, just writing a simple Tetris game is a lot of work to a new person.
But encrypting your resources obviously isn''t?

quote:
Imagine how much it would suck if someone downloaded your game that you cut your teeth on, took out your name on the loading screen, changed some graphics around and called it their own?
It''s a Tetris clone; who cares? That person hasn''t learned anything, but you have, and you''ll go on to greater heights while they''ll continue trying to pass other people''s work off as their own.

Besides, with the number of freely available implementations of several games with source, this scenario is about as likely as an elephant becoming a Mariachi singer.

quote:
Also, having encoded files looks a bit more professional than just having bitmaps in a folder...
Nope. Besides, if you''re a beginner, why are you concerned about "looking professional"? It''s still just a Tetris clone.

quote:
...as well as using compression allows you to distribute it easier.
Use InstallShield or NSIS and make an installer.

quote:
In my case, I plan to create a tool to allow someone to mod the graphics and such, but with built in safeguards to still display that I did the underlying work.
Entertaining. Perhaps gratifying and ego-inflating, but ultimately pointless.

Allow me to explain my rationale: Dijkstra said that "premature optimization is the root of all evil." While this is, of course, a somewhat farcical statement, it has a definite ring of truth to it, and it extends beyond mere source code. If you''re building encryption to learn encryption, good. If you''re writing compression algorithms to grok compression, excellent. If, however, you''re incorporating these features for the sole purpose of "locking down" your Tetris clone, you''re wasting your time (and my processing power). Too frequently we get beginners (this is For Beginners, right?) misled by those who think they are advanced into squandering time and effort on low-return activities, like writing a game engine when they really should be writing the game.

Share this post


Link to post
Share on other sites
The truth is, even if someone would want to steal a beginner (with all due respect!)''s Tetris clone and claim it for their own, how would it affect you? For one thing, let''s face it: there are so many Tetris clones out there, you won''t make a name for yourself with yet an other one, so why worry about fame? For an other, in the end someone could just use print screen and extract your graphics manually from the game at runtime.

Get the game to work. Like previously stated, premature optimization is the root of all evil: you don''t even have a working game yet (I''m guessing?) so why focus on a feature that doesn''t serve any important purpose to the game itself?

Share this post


Link to post
Share on other sites
quote:
Original post by RuneLancer
Get the game to work. Like previously stated, premature optimization is the root of all evil: you don't even have a working game yet (I'm guessing?) so why focus on a feature that doesn't serve any important purpose to the game itself?
Depending on how you design the architecture of your game, adding an encryptor/decryptor feature at the end can be a pain in the ass. Optimization is not a feature. Encryption is, unfortunately.

Pretty much the same scenario as whether to load your map as a text file or a format of your own. If you want it easy, you start with text files. Later on you will realize that this is not a good idea because you worry about someone else is modifying your map, and think about creating your own format. However, if you want to do that, Notepad can no longer be your map editor; thus you have to make your own editor. You know it that you must finish the map editor before your finish the game.

In essence, it depends on how you design your game such that adding such feature is not a pain in the ass. You need to keep in mind that you will make your own encryptor/decryptor at the end, so you must make your image loader module as flexible as you can.

edit:
If you intend to encrypt your bitmap files only but not your sound files, you'd better not doing it at all. That just defeats the whole purpose of encryption. You should only have two options, encrypt all data or not at all.

[edited by - alnite on March 23, 2004 8:09:47 PM]

Share this post


Link to post
Share on other sites
Hi again,

I would like to thank everyone for the replies first since it''s a big help (especially Toolmaker. The link is kinda what I''m looking for). First of, if anyone is thinking that it''s a Tetris clone art that I want to secure, then it''s not. This is my third game (1st being Tetris and Pacman 2nd) and it''s a adventure sidescrolling game so I''ve put up a lot of art in it that''s why I just don''t want my friends go messing it up. Just like someone said, they can just modify it a little bit to make it different and they have a new game, and that would really suck. Again, thanks for the replies!!

Share this post


Link to post
Share on other sites
heh,

well what can I say guys, you make a good point.

actually, I do have one point to add about the advantage of encryption. Actually, moreso compression. If you have a bitmap for the "background" that''s a meg in size, it might be better to know some compression/decompression so that it''s easier to distribute. of course, you can always put it in a zip file as well, but anywho. I just think it''s a bad idea that a little tetris clone can take up 3 megs of hd space. sure, 3 megs isn''t much, but Activision was programming with 4K.

anyways, like I said, you guys have good points, and actually they kind of helped me out with my own path to development. I was spinning my wheels trying to optimize, when I realize that there''s other things I should be thinking about.

thanks.

Share this post


Link to post
Share on other sites
quote:
Original post by lukeyes
actually, I do have one point to add about the advantage of encryption. Actually, moreso compression. If you have a bitmap for the "background" that''s a meg in size, it might be better to know some compression/decompression so that it''s easier to distribute.
Before you get to compressing, choose a smart file format. Look into using JPEG and PNG for their own compression features, then consider additional compression - and use an existing library (eg zlib) rather than rolling your own.

Write the game, not fancy orthogonal code.

Share this post


Link to post
Share on other sites
hey guys, is there any "easy" way to hide your image files? i cant just rename my files from .bmp to .whatever because SDL only loads certain file types. also, that link someone posted didnt help much because it talked of more advanced features of c++ like linked lists, which i have no knowledge of yet. yes, this is only a simple pacman like game but i spent a lot of time making the artwork and dont want some ass just taking all my images. i guess its not that big of a deal. but if theres an "easy" way for me to do this, please enlighten me. thanks

Share this post


Link to post
Share on other sites
You can just apply a simple xor encryption on your resource files. It should be enough to deter any casual attempts on ''stealing'' your precious artwork And it''s relatively easy to implement to boot.





--{You fight like a dairy farmer!}

Share this post


Link to post
Share on other sites
quote:
Original post by graveyard filla
i cant just rename my files from .bmp to .whatever because SDL only loads certain file types.


I''ve never used SDL, but try this...

1'' Open MS Paint.
2'' Rename a bitmap (in any program) to, say, Mybitmap.mp3
3'' Open Mybitmap.mp3 with MS Paint (type in *.* and it''ll show every file).
4'' Magic! Despite suddently becoming an MP3, your bitmap is STILL LOADED! :D

Actually, step 4 is wrong. Why? You can call decaf "coffee" all you want, it''s still just an atrocity. (...ok, so you can rename your file to whatever you want, it still contains bitmap data The extension is pretty much only used to keep a tab on what kind of data''s in there. In an informative sense and none other.)

But... wouldn''t users just press print screen and extract your sprites anyways? And honestly, does it matter?

Share this post


Link to post
Share on other sites
i dunno, i guess it doesnt REALLY matter. it was just a real pain in the ass to make the nice sprites/textures i made and i dont want people jacking it for their own game. but i guess it dont matter, i mean whos gunna use a donkey head and a bunch of walking boxing gloves in their game? altho they can still jack my textures, but whatever. im not a great artist, but i LOVE paint shop pro, it ROCKS (no art skill required... just clicking buttons to make nice textures)

Share this post


Link to post
Share on other sites