5

I am making a little webgame that has tasks and solutions, the solutions are solved by entering a code given to user after completion of a task. To have some security (against cheating) i dont want to store the codes genereted by the game in plain text. But since i need to be able to give a player the code when he has accomplished the task i cant hash it since then i cant retrive it.

So what is the most secure way to encrypt/decrypt something using python?

4
  • look here: stackoverflow.com/questions/172486/… Commented Jun 25, 2009 at 12:54
  • 2
    How would you be able to cheat if you stored those codes in plain text? Commented Jun 25, 2009 at 13:02
  • Just in cause of someone getting a hold of the database table with the codes... Commented Jun 25, 2009 at 14:51
  • Well that wouldn't be cheating, but hacking. Commented Jun 25, 2009 at 21:18

4 Answers 4

5

If your script can decode the passwords, so can someone breaking in to your server. Encryption is only really useful when someone enters a password to unlock it - if it remains unlocked (or the script has the password to unlock it), the encryption is pointless

This is why hashing is more useful, since it is a one way process - even if someone knows your password hash, they don't know the plain-text they must enter to generate it (without lots of brute-force)

I wouldn't worry about keeping the game passwords as plain-text. If you are concerned about securing them, fix up possibly SQL injections/etc, make sure your web-server and other software is up to date and configured correctly and so on.

Perhaps think of a way to make it less appealing to steal the passwords than actually play the game? For example, there was a game (I don't recall what it was) which if you used the level skip cheat, you went to the next level but it didn't mark it as "complete", or you could skip the level but didn't get any points. Or look at Project Euler, you can do any level, but you only get points if you enter the answer (and working out the answer is the whole point of the game, so cheating defeats the playing of the game)

If you are really paranoid, you could possibly use asymmetric crypto, where you basically encrypt something with key A, and you can only read it with key B..

I came up with an similar concept for using GPG encryption (popular asymmetric crypto system, mainly used for email encryption or signing) to secure website data. I'm not quite sure how this would apply to securing game level passwords, and as I said, you'd need to be really paranoid to even consider this..

In short, I'd say store the passwords in plain-text, and concentrate your security-concerns elsewhere (the web applications code itself)

Sign up to request clarification or add additional context in comments.

2 Comments

I agree with you for the most part, and this is what i proporbly end up with. I'm too thinking that if i make it "impossible" to do sql injectons and stuff like that there is noe problem in storing the level passwords in plain text, since no one should be able get them out, but if they get them out, they can "run" trough the game without a problem and be the winner... So I was thinking that just to be on the safe side, some encryption wouldnt hurt.
And GPG encryption solutions does seem a little paranoid yes :)
5

The most secure encryption is no encryption. Passwords should be reduced to a hash. This is a one-way transformation, making the password (almost) unrecoverable.

When giving someone a code, you can do the following to be actually secure.

(1) generate some random string.

(2) give them the string.

(3) save the hash of the string you generated.

Once.

If they "forget" the code, you have to (1) be sure they're authorized to be given the code, then (2) do the process again (generate a new code, give it to them, save the hash.)

4 Comments

as the question said, hashes are no good, since he has to be able to tell the player the password
@Adrian: Good point. However, I think the question is flawed. Or, this isn't real security, in which case encryption doesn't really help much.
There was another post but was deleted that I think was a pretty good idea: Generate the hash of a string in the from username+"mygame"+level (maybe also add a salt for better security?) I don't know who posted it and deleted it afterwards, but I think it's a nice approach.
@Adrian : I don't see the problem with telling the password. If the user ask for it, delete the old one, create a new one and hash it...
2

If it's a web game, can't you store the codes server side and send them to the client when he completed a task? What's the architecture of your game?

As for encryption, maybe try something like pyDes?

Comments

0

Your question isn't quite clear. Where do you want the decryption to occur? One way or another, the plaintext has to surface since you need players to eventually know it.

Pick a cipher and be done with it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.