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

Started by
17 comments, last by KuroKage 20 years ago
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!!
Advertisement
Indeed you can. Writing your own encryption program is fun! I think there are many articles about this one everywhere, just use google.
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]
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
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.
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:.
Allow me to ask the question: Why?

Modding games is incredibly popular these days, and I think that any good game design will support user modification and user-created content. Or is there some particular reason why you''d go to all this trouble?
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.

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.
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.
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?

This topic is closed to new replies.

Advertisement