I mad this lock program to make the user to enter a code before playing the game and here it is

Code:

Lbl ST
Input "LOCK CODE:",CB
If CB=(desired 4 digit code here)
Then
Goto PG
End
If CB≠(same 4 digit code as stated above)
Then
Disp "INCORRECT"
Goto ST
End
Lbl PG
(pgrm starts here)

What i was wondering if u can make a lock program also to have the user enter a code before u can edit the progam
jlc4nebgred1 wrote:
I mad this lock program to make the user to enter a code before playing the game and here it is

Code:

Lbl ST
Input "LOCK CODE:",CB
If CB=(desired 4 digit code here)
Then
Goto PG
End
If CB≠(same 4 digit code as stated above)
Then
Disp "INCORRECT"
Goto ST
End
Lbl PG
(pgrm starts here)

What i was wondering if u can make a lock program also to have the user enter a code before u can edit the progam


First thing, that is horrible code for BASIC (poor structure, memory leaks, etc...) Avoid Gotos and Lbls at all costs (unless completely unavoidable)

Second, unless you are good at ASM, your second question is out.
>.< Holy memory leak, Batman. Let's rewrite that code:


Code:
Lbl ST
Input "LOCK CODE:",CB
If CB≠(same 4 digit code as stated above)
Then
Disp "INCORRECT"
Return
End
(pgrm starts here)


Unfortunately you can't do the same thing with editing without assembly and keyhooks.
KermMartian wrote:
>.< Holy memory leak, Batman. Let's rewrite that code:


Code:
Lbl ST
Input "LOCK CODE:",CB
If CB≠(same 4 digit code as stated above)
Then
Disp "INCORRECT"
Return
End
(pgrm starts here)


Unfortunately you can't do the same thing with editing without assembly and keyhooks.


Oh come on kerm, that doesn't do the same thing of repeating the question (and you left the lbl in there)!


Code:
0 -> CB
While(CB != <4 digit code>)
Input "LOCK CODE:", CB
End
(program)
Ha, even better:


Code:

Repeat C=<4 digit code>
Input "LOCK CODE:", C
End
(program)
It is like an optimization battle =P


Code:
Lbl ST
Input "LOCK CODE:",CB
If CB=(desired 4 digit code here)
Then
Goto PG
End
If CB≠(same 4 digit code as stated above)
Then
Disp "INCORRECT"
Goto ST
End
Lbl PG



to


Code:
Repeat C=<4 digit code>
Input "LOCK CODE:", C
End


12 to 3 lines Laughing

And about editing: no, not really. You could lock it, but that is easy to undo.
Harq wrote:
It is like an optimization battle =P


Code:
Lbl ST
Input "LOCK CODE:",CB
If CB=(desired 4 digit code here)
Then
Goto PG
End
If CB≠(same 4 digit code as stated above)
Then
Disp "INCORRECT"
Goto ST
End
Lbl PG



to


Code:
Repeat C=<4 digit code>
Input "LOCK CODE:", C
End


12 to 3 lines 0x5

And about editing: no, not really. You could lock it, but that is easy to undo.



Well you could make the password hard to read or something.... like using getkeys and applying a formula to them... or you could use onblock or such...
I did this with one of my programs, Spikerunner. However, to make it harder I had it set up like this:

Lbl AA
Input "CODE? ",X
Goto ZZ
Lbl AB
<insert 4000-line program here>

Lbl ZZ
If X=<code>
Then
Goto AB
Else
Goto AA

Easily defeated by anyone who knows what they're doing, but if they just remove the first block they still won't know the password.
Ugh, that's some pretty disgusting use of labels, but I see your point. Why would you care if they know the password if they can just remove the Goto?
KermMartian wrote:
Ugh, that's some pretty disgusting use of labels, but I see your point. Why would you care if they know the password if they can just remove the Goto?


I don't think he was trying to write eloquent code. He thought you were hungry so he brought out the spaghetti.

Now really there's to many ways to get around that lock or any basic lock such as removing the checking/changing the required password or removing the password checking entirely.
Sure you can make it editable: put it into a string.


Code:
repeat 4=Length(Str1
input "Key:",Str1
end


Now, of course, safety of this kind of key is compromised easily, but i'm sure you can find a way to encrypt/protect Str1.

Code:

0->Rand
Repeat rand=(number here)
input "pass code",A
A->rand
End


I think this would be the best solution and it would be the hardest to crack because there is no way to find the random seed that would have a particular outcome.
TheStorm wrote:

Code:

0->Rand
Repeat rand=(number here)
input "pass code",A
A->rand
End


I think this would be the best solution and it would be the hardest to crack because there is no way to find the random seed that would have a particular outcome.


But then again there's always the problem of someone competent going into the program and editing it out. My solution will at least keep people from simply deleting the initial GOTO because the password prompt is at the end of the program, which is a lot harder to find. It keeps 8th graders from screwing with things they're not supposed to.
Not really because if its edit lock on eight grader will know how to unlock it anyway and if they do they can figure out how to do that, they sure as heck should know how to remove a Goto.
and even then using a combination of yours and mine would be even better.
I think this is the best solution.

Code:
0->rand
input "code",A
Goto Z
Lbl A
;Program here
Lbl Z
A->rand
If rand=#
Goto A

If they get it wrong the program just ends and it is impossible to backwards engineer it and it is at the end like yours since you think that is such a good idea. And of course edit locking the program would help.
Aye, I was although thinking about a rand-seed type solution. I think Storm's solution is the most optimal, but it's all academic here because locking BASIC programs like this is idiotic.
The _best_ solution is to hash the key via the OS' MD5 hashing routines, and refuse any (hashed) passcodes that don't match.

That's actually what I was doing for my password protect SE, but I couldn't get the basics (having it display things) working at all (I believe the actual checking stuff worked right..), so I kinda dropped the project. I think I still have the code somewhere, though.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement