# Need help protecting data

**URL:** <https://www.ruby-forum.com/t/need-help-protecting-data/131753>\
**Category:** Ruby\
**Created:** [March 13, 2008, 12:07am UTC](https://www.ruby-forum.com/t/need-help-protecting-data/131753 "2008-03-13T00:07:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![di3go](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@di3go](https://www.ruby-forum.com/u/di3go)\
**Post date:** [March 13, 2008, 12:07am UTC](https://www.ruby-forum.com/t/need-help-protecting-data/131753/1 "2008-03-13T00:07:25Z")

</div>

Hi

I need protect some data like photos and musics from a game, i really  
dont know how to do this, i was thinking in something like this, take  
the photo, translate to a string and store in the database and the  
database will be the mongoose. Have any other more efficient way?

Thx 🙂

---

<div class="post-metadata">

**Author:** ![di3go](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@di3go](https://www.ruby-forum.com/u/di3go)\
**Post date:** [March 13, 2008, 4:19pm UTC](https://www.ruby-forum.com/t/need-help-protecting-data/131753/2 "2008-03-13T16:19:32Z")

</div>

Diego B. wrote:

> Hi
> 
> I need protect some data like photos and musics from a game, i really  
> dont know how to do this, i was thinking in something like this, take  
> the photo, translate to a string and store in the database and the  
> database will be the mongoose. Have any other more efficient way?
> 
> Thx 🙂

( Not sure if I understood )  
you can create a compressed package of what you want to protect ( a rare  
format will be better), and then just change the extension of the file  
to mislead the offenders.

---

<div class="post-metadata">

**Author:** ![di3go](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@di3go](https://www.ruby-forum.com/u/di3go)\
**Post date:** [March 13, 2008, 6:44pm UTC](https://www.ruby-forum.com/t/need-help-protecting-data/131753/3 "2008-03-13T18:44:42Z")

</div>

Rodrigo B. wrote:

> Diego B. wrote:
> 
> > Hi
> > 
> > I need protect some data like photos and musics from a game, i really  
> > dont know how to do this, i was thinking in something like this, take  
> > the photo, translate to a string and store in the database and the  
> > database will be the mongoose. Have any other more efficient way?
> > 
> > Thx 🙂
> 
> ( Not sure if I understood )  
> you can create a compressed package of what you want to protect ( a rare  
> format will be better), and then just change the extension of the file  
> to mislead the offenders.

Hehe, i made a test with openssl and storing in mongoose, i think ppl  
will never, ever open it, but, well, its impossible to made a game with  
it XD on my notebook (celeron 1.5ghz) took 1 sec to read the data inside  
the database, decrypt and open it ( not a big file, 150k ), well in game  
its not less then 10mb per map, so…  
yea i will keep searching for a better solution =/

---

<div class="post-metadata">

**Author:** ![di3go](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@di3go](https://www.ruby-forum.com/u/di3go)\
**Post date:** [March 13, 2008, 7:09pm UTC](https://www.ruby-forum.com/t/need-help-protecting-data/131753/4 "2008-03-13T19:09:42Z")

</div>

On 13 Mar 2008, at 17:44, Diego B. wrote:

> Hehe, i made a test with openssl and storing in mongoose, i think ppl  
> will never, ever open it, but, well, its impossible to made a game  
> with  
> it XD on my notebook (celeron 1.5ghz) took 1 sec to read the data  
> inside  
> the database, decrypt and open it ( not a big file, 150k ), well in  
> game  
> its not less then 10mb per map, so…  
> yea i will keep searching for a better solution =/

OpenSSL performance is very dependent on the strength of key you use,  
not to mention that it’s a ropey library anyway 🙂

You’ll improve performance a bit by storing your encrypted game data  
in standard flat files and breaking it into lots of smaller files  
which decrypt on demand. Also for text data you’d be advised to  
compress it first before encrypting as that reduces the amount of data  
you have to encrypt and beyond a certain critical threshold should  
overall reduce processing time.

On the encryption front, use one of the symmetric cyphers - they’re  
not particularly secure but they’re usually computationally much less  
intensive that public/private key crypto.

The one big problem you’ll have to address though is how you’re going  
to hide the keys so that players can’t tamper. For network traffic  
this is easy (there’s a solution using a roll-your-own Hybrid Key  
Infrastructure in the presentation I pointed you to) but for  
distributed applications the keys have to reside on the machine  
running the application and are therefore easily discovered…

Ellie

## Eleanor McHugh Games With Brains

raise ArgumentError unless @reality.responds\_to? :reason

---

<div class="post-metadata">

**Author:** ![di3go](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@di3go](https://www.ruby-forum.com/u/di3go)\
**Post date:** [March 14, 2008, 4:38am UTC](https://www.ruby-forum.com/t/need-help-protecting-data/131753/5 "2008-03-14T04:38:35Z")

</div>

Hrr im a noob XD Now i know why the encrypt and decrypt was so slow \>.\<  
i was using DES, hrrrr  
Now with AES-256 i could decrypt 500mb of data in only 12sec with my  
slow notebook using a 9 character pass o.O lol this is fast, more than i  
was expecting and its very safe 🙂 im in love  
Now the problem is to store data in a file, need look around to see more  
stuffs 🙂

---

<div class="post-metadata">

**Author:** ![di3go](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@di3go](https://www.ruby-forum.com/u/di3go)\
**Post date:** [March 13, 2008, 8:27pm UTC](https://www.ruby-forum.com/t/need-help-protecting-data/131753/6 "2008-03-13T20:27:05Z")

</div>

Eleanor McHugh wrote:

> On 13 Mar 2008, at 17:44, Diego B. wrote:
> 
> > Hehe, i made a test with openssl and storing in mongoose, i think ppl  
> > will never, ever open it, but, well, its impossible to made a game  
> > with  
> > it XD on my notebook (celeron 1.5ghz) took 1 sec to read the data  
> > inside  
> > the database, decrypt and open it ( not a big file, 150k ), well in  
> > game  
> > its not less then 10mb per map, so…  
> > yea i will keep searching for a better solution =/
> 
> OpenSSL performance is very dependent on the strength of key you use,  
> not to mention that it’s a ropey library anyway 🙂
> 
> You’ll improve performance a bit by storing your encrypted game data  
> in standard flat files and breaking it into lots of smaller files  
> which decrypt on demand. Also for text data you’d be advised to  
> compress it first before encrypting as that reduces the amount of data  
> you have to encrypt and beyond a certain critical threshold should  
> overall reduce processing time.
> 
> On the encryption front, use one of the symmetric cyphers - they’re  
> not particularly secure but they’re usually computationally much less  
> intensive that public/private key crypto.
> 
> The one big problem you’ll have to address though is how you’re going  
> to hide the keys so that players can’t tamper. For network traffic  
> this is easy (there’s a solution using a roll-your-own Hybrid Key  
> Infrastructure in the presentation I pointed you to) but for  
> distributed applications the keys have to reside on the machine  
> running the application and are therefore easily discovered…
> 
> Ellie
> 
> ## Eleanor McHugh Games With Brains
> 
> raise ArgumentError unless @reality.responds\_to? :reason

Elllie, you helping me alot 🙂 i love ruby community

The big problem is to make the decryt fast, because the client never  
gonna change the files, just read, only when the client update, but this  
dont really need to be fast

I need more time to study, your slides seams very nice but im without  
time to read it \>.\< tomorrow i will!

I really like the maplestory system, well, it is very fast to read, ppl  
just fully cracked it now in the xentax forum, ive attached the source  
of the program to crack it, its write in python, when have a update take  
years to make the data.wz ( the file with all maple data ), now isnt one  
file with all the data, the nexon slipt in more files like map, mob,  
char, item,…  
The .wz files use ZLIB

Hrrrr i need a safe and fast to read way to store the game data,  
hrrrrr…

Thx alot for the help 🙂 really thx 🙂
