Board Logo
« A simple password protector »

Welcome Guest. Please Login or Register.
Jan 21st, 2018, 12:54am


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 hotthread  Author  Topic: A simple password protector  (Read 6131 times)
fender999
Member in Training
ImageImage


member is offline

Avatar




PM


Posts: 37
xx A simple password protector
« Thread started on: Jul 10th, 2006, 12:50pm »

Hi everybody!

I have a challenge, i challenge somebody to build a simple password protector, so when i try to access a file or something like that it comes up with a screen which you type the password into.

Also you must be able to change the file that is being protected by the password.
User IP Logged

Austin Farmer
Senior Member
ImageImageImageImageImage


member is offline

Avatar

what do you think of my new avatar? I designed it myself.

YIM YIM AIM
Homepage PM

Gender: Male
Posts: 599
xx Re: A simple password protector
« Reply #1 on: Jul 10th, 2006, 2:56pm »

Sounds Cool. Mine Might be a little bit weird tho, if it works,
User IP Logged

Awesome Hosting, That I work at
my forum: Click Here If your from kentucky pm me!
my site: Click Here
http://justliberty.conforums.com
uncleBen
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1679
xx Re: A simple password protector
« Reply #2 on: Jul 10th, 2006, 5:10pm »

You mean, if I had a "textfile.txt" and I wanted to open it with Notepad (or any other program), the file protector would pop up and ask for a password?

I don't really see how to do it without seriously messing (up) with my Windows. Actually I don't believe this could be done without Windows API, because you'll need to monitor opening files and terminate the process if someone got the password wrong.

I would see how to do it, if we were dealing with special (binary) files that only my program can read. Say data files for my game.

You could still open the file with notepad, but since it would be binary, you wouldn't understand much smiley
« Last Edit: Jul 10th, 2006, 5:13pm by uncleBen » User IP Logged

Passing arrays to subroutines, functions that work with any types, quick string indexing and much more - JBExtensions.

Tired of Minesweeper? Try TomatoSweeper
CodyDavis
New Member
Image


member is offline

Avatar

Who ever believe in Jesus will not parish Thus receive the gift of life


PM


Posts: 2
xx Re: A simple password protector
« Reply #3 on: Jul 11th, 2006, 10:01pm »

I font know if this what fender999 was talking about but here a example of what I made.

Code:
nomainwin
password$="justbasiceditor"
filedialog"Run File","*.exe", filename$
if filename$="" then wait
prompt"Whats the password"; pass$
if pass$=password$ then
let pass$=password$
end if
run filename$



 
User IP Logged

Now is the judgment of this world: now shall the prince of this world be cast out. (John 12:12-31
BJ Moore
Administrator
ImageImageImageImageImage


member is offline

Avatar

Do the right thing before doing things right...


Homepage PM

Gender: Male
Posts: 1512
xx Re: A simple password protector
« Reply #4 on: Jul 12th, 2006, 07:12am »

Cody -

You code is flawed -

It does not matter what you type for the password, the exe file will always be run.

Also - if you fail to select a file in the filedialog, then the program hits a wait statement. Since there is no GUI it causes the program to hang infinately in memory with no way to terminate it.

The fact is, there is no way to accomplish what fender999 is suggesting without seriously messing with the OS. If you created an encryption program and saved the files with a unique extension, then associated that extension with your app, it might work, and you might be able to do it with JB. It would not prevent other apps from opening your file and it would not prompt for a password if other apps tried to open the file, but atleast the contents would be scrambled and therefore not usable.

- Brad
« Last Edit: Jul 12th, 2006, 07:41am by BJ Moore » User IP Logged

Just Basic users can visit Liberty Basic Connection for many resources that can be used in your programming experience - goto http://www.freewebs.com/lb-connection.

Be sure to see the many useful articles at the LBNewsletter site at http://babek.info/libertybasicfiles/lbnews/
Austin Farmer
Senior Member
ImageImageImageImageImage


member is offline

Avatar

what do you think of my new avatar? I designed it myself.

YIM YIM AIM
Homepage PM

Gender: Male
Posts: 599
xx Re: A simple password protector
« Reply #5 on: Jul 12th, 2006, 07:33am »

OH chester lol, I was thinking we just had to make a file, whatever it is, and make the program open it with a password, not make it completely password protected from other programs..... I agree w/ you Brad, your idea would be the closest to what he wants.
User IP Logged

Awesome Hosting, That I work at
my forum: Click Here If your from kentucky pm me!
my site: Click Here
http://justliberty.conforums.com
nedarb
Member in Training
ImageImage


member is offline

Avatar

Twite eat this!


PM

Gender: Male
Posts: 22
xx Re: A simple password protector
« Reply #6 on: Sep 3rd, 2006, 7:15pm »

I'll try, is there a deadline?


thanks. grin
User IP Logged

Techno
Full Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 312
xx Re: A simple password protector
« Reply #7 on: Oct 20th, 2006, 06:04am »

I always thought that writing (the red) is hard to see... - It took me like 10 seconds to read it!!!
User IP Logged

Techno

Simply put, JB ROCKS!!!
Jamie
Senior Member
ImageImageImageImageImage


member is offline

Avatar

I try to do things right, it's often wrong, but I try.


Homepage PM

Gender: Male
Posts: 1228
xx Re: A simple password protector
« Reply #8 on: Oct 21st, 2006, 11:46am »

I know this is simple but thats what was specified! 3 lines of code and your there!
Code:
input "Type your password:";pass$
IF pass$ = "hello" Then print "Correct!" ELSE print "incorrect!!" : End
Run "notepad.exe"
 
User IP Logged

If you're ever being chased by a police dog, try not to go through a tunnel, over a seesaw, then jump through a hoop of fire. They're trained for that stuff

Home Integration & Automation http://www.jaylexsoftware.co.uk/

In the UK? Like DIY SOS on the BBC visit http://www.DIYSOSForum.co.uk
tborders
New Member
Image


member is offline

Avatar




PM


Posts: 2
laugh Re: A simple password protector
« Reply #9 on: Nov 18th, 2006, 10:27pm »

nomainwin

[main]

password$="pswd"
filedialog"Run File","*.exe", filename$
if filename$="" then wait
prompt"Whats the password"; pass$
if pass$=password$ then goto [4]
goto [main]
[4]
run filename$
end

This Code works perfect
User IP Logged

zanewonsey
Member in Training
ImageImage


member is offline

Avatar

RuneScape r@@lz


Homepage PM

Gender: Male
Posts: 43
xx Re: A simple password protector
« Reply #10 on: Nov 20th, 2006, 09:00am »

this code worked for me

Code:
pass$="hereugo"

[start]
cls
input "what is your password? "; zane$
if zane$=pass$ then
 notice "correct!!!"
 run "notepad.exe"
 end
else
 notice "nope..."
 goto [start]
end if
 
User IP Logged

3 nails+1 cross=forgiven
Welopez
Moderator
ImageImageImageImageImage


member is offline

Avatar

Never let your beliefs get in the way of learning.


PM

Gender: Male
Posts: 4407
xx Re: A simple password protector
« Reply #11 on: Nov 21st, 2006, 3:47pm »

Just to show I haven't fallen asleep, out here in the California sunshine, I wrote a tutorial with yet another password routine, but this one is so simple, it doesn't use a TXT or DAT file which a user might possibly hack. At least, not in this decade.
No-File Password Protection.


Choose any password you like from the DATA statements in the routine, or try and make up one of your own.
User IP Logged

JB 1.01
Win7 64bit, 4 GB RAM, Pentium 6200@2.13 GHz (laptop)
WinXP, 1 GB RAM, Intel N270@1.6 GHz (netbook)
NTW
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 15
xx Re: A simple password protector
« Reply #12 on: Dec 16th, 2006, 11:47am »

This is something that came with jb, I know it does not count so don't take me wrong, but this should help with what your wanting. Code:
nomainwin
enter$ = chr$(_VK_RETURN) : backspace$ = chr$(_VK_BACK)
bs = 2 'for some reason when you press the
'backspace key it shows up twice and
'deletes two charcters. This is used
'as a counter so the backspace only
'deletes one charcter at a time
'** if anyone knows how to fix this please
'** post it to the group. Thanks

WindowWidth = 285 : WindowHeight= 130
'center the window
UpperLeftX = (DisplayWidth-WindowWidth)/2
UpperLeftY = (DisplayHeight-WindowHeight)/2

'graphicbox is used to capture key input
graphicbox #pass.gb, 0,0,0,0
textbox #pass.tb, 1,20,275,25
'ok button optional
button #pass.default, "Ok", [ok],UL 100,60,70,25
open "Enter Password" for window as #pass
print #pass, "trapclose [quitpass]"
print #pass, "font courier_new 10 bold"
print #pass.gb, "setfocus"
print #pass.gb, "when characterInput [letter]"
timer 400, [t]
wait

[t]
'if enter = 1 the enter key was pressed
if enter = 1 then timer 0 : goto [ok]
print #pass.gb, "setfocus"
wait

[letter]
timer 0
key$ = Inkey$ : key$ = left$(Inkey$, 2) : vkey$ = right$(key$,1)
if vkey$ <> enter$ and vkey$ <> backspace$ then
b$ = b$ + key$ : b = len(b$) : fill$ = ""
for x = 1 to b:fill$ = fill$ + "*" : next x 'fill mask with "*"
print #pass.tb, fill$ : print #pass.gb, "setfocus"
end if
if vkey$ = enter$ then enter = 1
if vkey$ = backspace$ and bs = 2 then
b = len(b$) : b=b-1 : b$ = left$(b$,b) : fill$ = ""
for x = 1 to b : fill$ = fill$ + "*" : next x 'fill mask with "*"
print #pass.tb, fill$ : print #pass.gb, "setfocus"
bs = bs +1: if bs = 3 then bs = 1 else if bs = 1 then bs = 2
end if : timer 400, [t]
wait

[quitpass]
timer 0
close #pass
end

[ok]
timer 0
if b$ = "ok" then 'password is "ok"
'do events for correct password
notice " " + chr$(13) + "Correct password" : print #pass.tb, ""
print #pass.gb, "setfocus" : b$ = ""
enter = 0 'leave timer off if opening a new window "timer 0"
timer 400, [t]
else
'do events for wrong password
notice " " + chr$(13) + "Wrong Password!" : print #pass.tb, ""
print #pass.gb, "setfocus" : b$ = "" : enter = 0 : timer 400, [t]
end if
wait

 
User IP Logged

StarrV
Guest
xx Re: A simple password protector
« Reply #13 on: Dec 16th, 2006, 4:09pm »

on Dec 16th, 2006, 11:47am, NTW wrote:
This is something that came with jb, I know it does not count so don't take me wrong, but this should help with what your wanting. Code:
nomainwin
enter$ = chr$(_VK_RETURN) : backspace$ = chr$(_VK_BACK)
bs = 2 'for some reason when you press the
'backspace key it shows up twice and
'deletes two charcters. This is used
'as a counter so the backspace only
'deletes one charcter at a time
'** if anyone knows how to fix this please
'** post it to the group. Thanks

WindowWidth = 285 : WindowHeight= 130
'center the window
UpperLeftX = (DisplayWidth-WindowWidth)/2
UpperLeftY = (DisplayHeight-WindowHeight)/2

'graphicbox is used to capture key input
graphicbox #pass.gb, 0,0,0,0
textbox #pass.tb, 1,20,275,25
'ok button optional
button #pass.default, "Ok", [ok],UL 100,60,70,25
open "Enter Password" for window as #pass
print #pass, "trapclose [quitpass]"
print #pass, "font courier_new 10 bold"
print #pass.gb, "setfocus"
print #pass.gb, "when characterInput [letter]"
timer 400, [t]
wait

[t]
'if enter = 1 the enter key was pressed
if enter = 1 then timer 0 : goto [ok]
print #pass.gb, "setfocus"
wait

[letter]
timer 0
key$ = Inkey$ : key$ = left$(Inkey$, 2) : vkey$ = right$(key$,1)
if vkey$ <> enter$ and vkey$ <> backspace$ then
b$ = b$ + key$ : b = len(b$) : fill$ = ""
for x = 1 to b:fill$ = fill$ + "*" : next x 'fill mask with "*"
print #pass.tb, fill$ : print #pass.gb, "setfocus"
end if
if vkey$ = enter$ then enter = 1
if vkey$ = backspace$ and bs = 2 then
b = len(b$) : b=b-1 : b$ = left$(b$,b) : fill$ = ""
for x = 1 to b : fill$ = fill$ + "*" : next x 'fill mask with "*"
print #pass.tb, fill$ : print #pass.gb, "setfocus"
bs = bs +1: if bs = 3 then bs = 1 else if bs = 1 then bs = 2
end if : timer 400, [t]
wait

[quitpass]
timer 0
close #pass
end

[ok]
timer 0
if b$ = "ok" then 'password is "ok"
'do events for correct password
notice " " + chr$(13) + "Correct password" : print #pass.tb, ""
print #pass.gb, "setfocus" : b$ = ""
enter = 0 'leave timer off if opening a new window "timer 0"
timer 400, [t]
else
'do events for wrong password
notice " " + chr$(13) + "Wrong Password!" : print #pass.tb, ""
print #pass.gb, "setfocus" : b$ = "" : enter = 0 : timer 400, [t]
end if
wait

 


Sorry, that do not count. You need to work on creating your own. Sorry if I said it in a bad way.

Here is my Program, I dont know if this what is wanting on here but its my way of making something work. Ill work on it more.

Code:
nomainwin
pass$="jbeditor"
filedialog"Open EXE File","*exe", exe$
if exe$="" then end
prompt"What is the Password to open this program?"; password$
if password$=pass$ then
run exe$
else
notice"ERROR!!!"+chr$(13)+_
"You do not know the Passowrd. You can not enter with out the Password. Retry!"
end if
end


 
User IP Logged

NTW
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 15
xx Re: A simple password protector
« Reply #14 on: Dec 16th, 2006, 6:51pm »

Quote:
Sorry, that do not count. You need to work on creating your own. Sorry if I said it in a bad way.

Here is my Program, I dont know if this what is wanting on here but its my way of making something work. Ill work on it more.



I was just showing an example. you know one that he could look while coding in JB. see how it all works
« Last Edit: Dec 16th, 2006, 6:52pm by NTW » User IP Logged

Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls