Okay, well I was reading this n' all and I decided I liked witchbomber's code so I copied it into an empty program and ran it... by ALL means no offense... but it lacked. Therefor I, er, tweaked it a bit. Just a little I promise.
Anywho though, onto the good stuff. The code in this program is simple enough to the point where I think it can be run in even earlier versions of DB... not sure though so don't hurt me
(. I added username, changed the password stuff, and added ENCODED saving and loading of the password. Mind you the level of encoding was designed to keep SOME people from deciphering it. However it's in ASCII (American Standard Code for Information Interchange) and there are MANY books ect. out there that can help someone decode it with ease. So my point is if you plan on making some top-level government security program... i'd recommend increasing how many times it encodes it or something of the like.
rem Note the current directory for shorter refrence
homedir$=get dir$()
rem Username support
print "«Save File Section»"
input "Username: ", username$
rem Password entry loop
loop:
cls
rem Re-print the username section
print "«Save File Section»"
print "Username: "+ username$
rem Recognize what the user presses as part of the password as long as it's not backspace
if scancode()>0 and scancode()<14 then password$=password$+inkey$()
if scancode()>14 then password$=password$+inkey$()
rem Recognize backspace being pressed
if scancode()=14
password$=left$(password$,len(password$)-1)
display$=left$(display$,len(display$)-1)
endif
rem Make sure it only writes 1 "*" to the screen
display$=""
rem Calculate how many *s to write to the screen
for x=1 to len(password$)
display$=display$+"*"
next x
rem Print "Password: " and the amount of *s their are
print "Password: "+display$
rem Make it slow down so it doesn't read multiple characters
wait 1
rem Attempt to make the cls move faster
sync
end_loop:
rem If a key is pressed (other than Enter) restart the loop
if scancode()>0 then goto loop
rem If enter is not pressed wait until something is
if returnkey()=0
goto end_loop
else
rem If enter is pressed end the password entry section and go onto saving the password
if returnkey()=1 then goto save_info
endif
rem Save the password under "current direcroy\Profiles\Username\Password.dat"
save_info:
overwrite:
rem Get the length of the password
passlen=len(password$)
rem Assure that it doesn't put a 0 before the encoding
e=0
rem Determine the encoded version of the password
for a=1 to passlen
e=e+1
a$=mid$(password$,a)
b=asc(a$)
b$=str$(b)
if e=0 or e=1 then c$=b$+" "
if e>1 then c$=c$+b$+" "
next a
rem Note where to save to for shorter refrence
theirsave$=homedir$+"\Profiles\"+username$
rem Make sure the user's folder exists and if not make it
if path exist(theirsave$)=0 then make directory theirsave$
rem Save the encoded password to the save file
if file exist(theirsave$+"\Password.dat")
delete file theirsave$+"\Password.dat"
goto else
else
else:
open to write 1,theirsave$+"\Password.dat"
rem The » is so the loading knows where to stop
write string 1,c$+"»"
close file 1
endif
rem Read password from file
restartload:
cls
rem Ask which user it should load
print "«Load File Section»"
input "Username: ",username2$
rem Fix the problem with going past the input
if username2$>""
rem Read the encoded password from the user's save file
open to read 1,homedir$+"\Profiles\"+username2$+"\Password.dat"
read string 1,origpass$
close file 1
else
goto restartload
endif
cls
rem Calculate the number of characters in the encoded password
passlen=len(origpass$)
rem Assure that it doesn't read a -1
b=0
rem Decode the encoded password
for a=1 to passlen
start:
b=b+1
if a$=" " and b=2 then c=val(a$):oneletter$=chr$(c):b=0:loadedpass$=oneletter$:goto start
if a$=" " and b=3 then c=val(b$+a$):oneletter$=chr$(c):b=0:loadedpass$=loadedname$+oneletter$:goto start
if a$=" " and b=4 then c=val(c$+b$+a$):oneletter$=chr$(c):b=0:loadedpass$=loadedpass$+oneletter$:goto start
if a$=" " and b=5 then c=val(d$+c$+b$+a$):oneletter$=chr$(c):b=0:loadedpass$=loadedpass$+oneletter$:goto start
if b=2 then b$=a$
if b=3 then c$=b$:b$=a$
if b=4 then d$=c$:c$=b$:b$=a$
if b=5 then goto counterror
a$=mid$(origpass$,a)
next a
rem Print the final results
print "Username="+username2$
print "Password="+loadedpass$
rem End the program
end
rem Error handling
counterror:
cls
print "Either the save file is corrupt, or this program is corrupt."
print "If you're sure it is not the save file, please re-download."
print "If problems persist, please contact post a reply on the forum."
print "(Press any key to end this program.)"
suspend for key
cls
Quote: "System Specs: P4 1.6Ghz, 512MB RAM, ATI Rage 128 GL PCI Graphics Card, 17" Monitor, AC'97 Audio, Windows XP Professional on C:\, Windows 98 SE on D:\, A:\ 3½" Floppy, C:\ 80GB Western Digital, D:\ 4GB Fujitsu, E:\ 56x CD-Rom, F:\ 16x/12x/40x CD/RW"