LoginLogin

How do I create a password nobody can view in a program?

Root / Programming Questions / [.]

MorganCreated:
I'm making a puzzle game that requires the player to figure out the password for a door leading to the next room by solving certain puzzles; and I want to make it so that the person playing it can't look through the game's code for the password to said door. Is there a way to hide the password from the player? And if so how? I know that "Escape the office" did something to make it so you couldn't view the password in the code, but I don't know what the creator did to make it that way.
SpoilerThe game would truly be ruined if it can't have this feature.

The program needs to be able to identify whether a string is a certain value or not, without directly storing that value. This can be accomplished by encrypting the string, and checking if that matches the encrypted value of the target string. There are many options for encryption. You could also make a 'hash function'. This will give some 'false positives', inputs which will be identified as a correct password even though they're not. But, you can make the probability of a hash collision vanishingly small by choosing a hash function with a large output space.

Remember that people could just modify the program to remove the part that requires the password, so if someone really wants to cheat, you can't stop them.

Good point 12Me21. In the big picture, you can't make it 'impossible', you can only make it more difficult, until it's difficult 'enough'. If bypassing the check isn't difficult 'enough' for your purposes, the next step you might try is encrypting the level information, with the raw password as the key. To reiterate: this still does not make your system impossible to crack, just more difficult. There is a next step you can take after that, and a next step, to make it more difficult, there will always be a next step.

Lol, it would have to be unbreakable, but that's okay, I think I'll just do it where once somebody solves 5 puzzles, (With 5 separate keys) I will combine them into one game as a whole, then make 5 more. Anyway, thanks for you're help on the subject, I'd definitely come back for this information once the first part of my game/plan is complete.

The biggest reason why is because the game is kind of a "Whoever can solve it first gets a reward" type of thing. I really want it to be a game that people come together and try to solve, I'm not sure people will be that interested in trying to solve it, but with the way I'm making it, you should (psychologically) want to try to solve it...I hope I explained that right. Thanks for you're help again!

it would have to be unbreakable
Well, it can't be, but the good news is no, it wouldn't have to be. In this case, hard 'enough' would be hard enough that the time it takes to defeat the system is likely greater than the time it takes to solve the game.

Well, it can't be, but the good news is no, it wouldn't have to be. In this case, hard 'enough' would be hard enough that the time it takes to defeat the system is likely greater than the time it takes to solve the game.
Don't be too sure, the language and decode puzzles that I plan on implementing in the game will be a lot like fez, and they will be quiet the challenge. And the idea of this game is the first person to beat room one, (First) and the person who beats room two (first) and so forth so on; (They'd need to prove it via image on miiverse or SB source) gets they're name in the room saying that they were the first to solve and beat it, (Kind of like a leaderboard) and, (In the very large project I'm slowly working on that will take months to make) they will also get they're choice of ether 1) A sprite that they make in my large game project 2) A character named after them in my large game project, or 3) They're name in the credits. *Note that the rewards specified are very much so subject to change* I adore the idea of players coming together trying to solve puzzles...sorry if that was a mouth full.

Don't be too sure
Sure about what? Sure that 'unbreakable' can't be achieved? I'm sure.

Don't be too sure
Sure about what? Sure that 'unbreakable' can't be achieved? I'm sure.
No, I meant don't be too sure that "the time it takes to defeat the system is likely greater than the time it takes to solve the game"

I know that it can't be unbreakable lol.

Don't be too sure
Sure about what? Sure that 'unbreakable' can't be achieved? I'm sure.
No, I meant don't be too sure that "the time it takes to defeat the system is likely greater than the time it takes to solve the game"
Ah, right. No, since 'unbreakable' is out, what remains is to determine what 'enough' means in 'hard enough'. I was trying to express that, for your purposes, hard 'enough' would be if the time it takes to crack it is longer than the time it takes to win in a regular fashion. If the reward goes to the first person, and the first person who tries cheating takes longer than the first person who plays and wins properly, then it is hard 'enough' that you can be reasonably sure the reward goes to the right person. So, add encryption and such measures until you're comfortable that the time it takes to cheat is longer than the time it takes to win conventionally.

Thanks square fingers! I think I'll just finish making the game and then decide what kind of encryption to use. =)

well, it would really depend on how much the person wants the code, what you could do is use sprite numbers and letters, change the numbers and hide it all. another thing is just random numbers, make a wild goose chase, make them think that its something really hard then just make a 2nd function that will give you your key, your could make a program that changes the value of the letters, in my game there's a part where you use a keyboard to do the numbers as fast as possible but every time you do it all the values change randomly, it shows what each new value is on the top screen, but its for something else in my game.. anyways, there's one more way but its complicated so ill save it for now.

well, it would really depend on how much the person wants the code, what you could do is use sprite numbers and letters, change the numbers and hide it all. another thing is just random numbers, make a wild goose chase, make them think that its something really hard then just make a 2nd function that will give you your key, your could make a program that changes the value of the letters, in my game there's a part where you use a keyboard to do the numbers as fast as possible but every time you do it all the values change randomly, it shows what each new value is on the top screen, but its for something else in my game.. anyways, there's one more way but its complicated so ill save it for now.
Thanks Picy3, I still have to figure a couple things out...I think I might make a regular, difficult but not too difficult puzzle game, (Using a way of encrypting the code) And a contest mode with 10 or 20 levels, (Which will use file keys (Like for programs)

ok cool.

Hey, could I have some help? I'm trying to make a password system(One that would save your password)for a bank-account system for my game. But I can't seem to get it right. Here's my code:
ACLS
@ACCOUNTCREATION1
IF CHKFILE("TXT:PS")==FALSE THEN
P$=DIALOG("","Please type your password",14)
SAVE "TXT:PS",P$
WAIT 1
GOTO @ACCOUNTCREATION2
ENDIF
IF CHKFILE("TXT:PS")==TRUE THEN
DIALOG "Loading your most recent password..."
WAIT 1
LOAD "TXT:PS",FALSE
WAIT 1'Again
GOTO @ACCOUNT
ENDIF
That's what I have so far---But it doesn't seem to be working. Could anyone post a copy of this code, but working? Or a completely new set of code with the same effect I'm looking for? Please :(

You need to load the file into a string:
P$=LOAD("TXT:PS",FALSE)