Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Help with my string cracker please?

Author
Message
yuri_dragon 17
17
Years of Service
User Offline
Joined: 7th Jan 2009
Location:
Posted: 8th Jan 2009 00:40
I need help. My program guesses a string by randomly guessing characters and if they're right, it keeps them.
I cannot figure out how to make it sequential ie. it will first guess the first character in the string a$(~) then the second one (!) and so on.

Here is the program:

`set up
a$=" ~!@@#$%^&*()_+QWERTYUIOP{}|ASDFGJHJKL:ZXCVBNM<>?`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./"
randomize timer()
hide mouse
sync on
set text font "Courier New"
set text size 14

`asks for string, or generates a random one
print "STRING CRACKING PROGRAM"
start:
print "Enter the string to guess (leave blank for random):"
input s$
e=len(s$)
if s$="" then input "How many characters should the random string be? ";e
if s$=""
for q=1 to e
s$=s$+mid$(a$,rnd(len(a$)));
next q
endif

`sets up array
dim r$(e)

`core
f=timer()
while w$<>s$
inc o
`randomly guesses letters, if they're correct, it keeps them
for a=1 to e
if r$(a)<>mid$(s$,a) then r$(a)=mid$(a$,rnd(len(a$)))
next a
w$=""
for a=1 to e
w$=w$+r$(a)
next a
cls
text 5,5,w$
text 5,25,s$
sync
endwhile
f=timer()-f

`prints the results
print
print
print
print

print "It took ";o;" tries and ";f/1000;" seconds to guess your string."

wait 2500
input "Again? ";g$
if g$="yes" then goto start
Not_Maindric
18
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 8th Jan 2009 01:30
Use a "For...Next" loop to check every possible character.

Also, post you code in a code snippet next time please, foe example:




* The band, visit them at Dopearmy.com (Warning, foul language.)
yuri_dragon 17
17
Years of Service
User Offline
Joined: 7th Jan 2009
Location:
Posted: 8th Jan 2009 15:29
Oh, ok, sorry. I didn't know how to do that.
But what do you mean use a for-next loop?

Login to post a reply

Server time is: 2026-07-05 15:02:58
Your offset time is: 2026-07-05 15:02:58