1. Random Password
I'm trying to write a simple DOS program that makes a random 6 number password
when you press enter, but for somereason it won't start when I press enter,
it just starts on its own and doesn't stop, is there a way I can fix this?
How do I get it to print six random numbers on one line if I can only use
one %d command in a puts() command?
(I just started programming about 4 days ago)
2. Re: Random Password
Alex,
You must use 'printf()' instead of puts() to use '%d'. 'puts()' is for
strings only.
Try this instruction:
printf(1,"%06d\n",{rand(999999)})
and please look up the description for 'printf'.
Have a nice day, Rolf
----------------------------------------------------
| Dr.Rolf Schröder | E B |
| DESY MST-1 | C |
| Notkestraße 85 | D |
| D-22603 Hamburg | A |
| Earth |-------------------------------|
| Solar System | Phone : +49-40-8998-2628 |
| Milky Way | Fax : +49-40-8994-2628 |
| Local Group | mailto:Rolf.Schroeder at DESY.de |
| Known Universe | http://adweb.desy.de/~rolf |
----------------------------------------------------
3. Re: Random Password
Hi Alex welcome to the programming world :)
It's always good if you can post your code or a sample of your problem so it's
easier to us know what's wrong.
You should check printf or sprintf routines to print a number the way you want
to.
Best Regards,
Guillermo Bonvehi
On Thu, 29 Jul 2004 23:19:22 -0700
Alex Blanchette <guest at RapidEuphoria.com> wrote:
>
>
> posted by: Alex Blanchette <caithman at juno.com>
>
>
> I'm trying to write a simple DOS program that makes a random 6 number password
> when you press enter, but for somereason it won't start when I press enter,
> it just starts on its own and doesn't stop, is there a way I can fix this?
> How do I get it to print six random numbers on one line if I can only use
> one %d command in a puts() command?
>
> (I just started programming about 4 days ago)
4. Re: Random Password
Alex Blanchette wrote:
>
>
> I'm trying to write a simple DOS program that makes a random 6 number password
> when you press enter, but for somereason it won't start when I press enter,
> it just starts on its own and doesn't stop, is there a way I can fix this?
> How do I get it to print six random numbers on one line if I can only use
> one %d command in a puts() command?
>
> (I just started programming about 4 days ago)
>
Hi,
This what i use to make "random" password.
-- shuffl.e
global function shuffle(sequence s)
-- randomly shuffle the elements of a sequence
-- written by Gabriel Boehme
-- based Jiri Babor's Euphoria interpretation of the "uniformly random"
-- 1963 shuffle algorithm written by L.E. Moses and R.V. Oakford
integer r
object temp
for i = length(s) to 2 by -1 do
r = rand(i)
temp = s[r]
s[r] = s[i]
s[i] = temp
end for
return s
end function
--
-- mycode
-- random.exw
include shuffl.e
sequence str, word
str = "0123456789ABCDEFGHIJKLMNOOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
word = {}
for n=1 to 10 do
word &= str[rand(length(str))]
end for
puts(1, word)
?getc(0)
--
5. Re: Random Password
Alex Blanchette wrote:
>
>
> I'm trying to write a simple DOS program that makes a random 6 number password
> when you press enter, but for somereason it won't start when I press enter,
> it just starts on its own and doesn't stop, is there a way I can fix this?
> How do I get it to print six random numbers on one line if I can only use
> one %d command in a puts() command?
>
> (I just started programming about 4 days ago)
Hello Alex:
First of all, to make Euphoria wait until a key is pressed, you need
the wait_key() function, perhaps as follows:
include get.e
integer key, password
key = wait_key() -- program will pause here until you hit a key
Then, below that, you put the code to generate a random number
password = rand(999999) -- up to 6 digits
Now, that random number may sometimes have 6 digits, but most often
it will be shorter, as 999999 is just the maximum value, zero will be
the minimum. So you want to always display 6 digits regardless of the
value:
printf(1,"%06d",password)
You may also want to add some prompts so users of your program will
know what to do, so the complete program might look like this:
include get.e
integer key, password
puts(1,"Press the enter key:")
key = wait_key()
password = rand(999999)
printf(1,"\nYour password is: %06d",password)
6. Re: Random Password
irv mullins wrote:
>
> Alex Blanchette wrote:
> >
> >
> > I'm trying to write a simple DOS program that makes a random 6 number
> > password
> > when you press enter, but for somereason it won't start when I press enter,
> > it just starts on its own and doesn't stop, is there a way I can fix this?
> > How do I get it to print six random numbers on one line if I can only use
> > one %d command in a puts() command?
Sorry, I left off the part about how to get 6 numbers on one line:)
nclude get.e
integer key, password
puts(1,"Press the enter key:")
key = wait_key()
puts(1,'\n')
-- To generate 6 numbers, here's one way:
for i = 1 to 6 do
password = rand(999999)
printf(1,"%02d ",password)
end for
7. Re: Random Password
if you compute digits seperately
then you could do something like this.
I'm using hex pairs for the password here.
--6 digit password
sequence v
v = {}
for i = 1 to 3 do
v &= rand(256)-1
--add some delay.
--You might reject having 2 identical numbers in a row, etc..
end for
printf(screen, "%02x%02x%02x --\n",
v[1] & v[2] & v[3] )
8. Re: Random Password
Thank you everyone for your gracious help, I admit I was a bit skeptical about
asking for help on a forum due to the fact that most forums have those "3l337"
people that will "Flame" you for asking anything related to beginners level
of work.
Thy name is but a short lived word,
Thy life is a forever ending story...
9. Re: Random Password
Alex Blanchette wrote:
>
> Thank you everyone for your gracious help, I admit I was a bit skeptical about
> asking for help on a forum due to the fact that most forums have those "3l337"
> people that will "Flame" you for asking anything related to beginners level
> of work.
Despite our being very elite (nay, most elite), we can't help but be
nice because some of us started out as newbies, too.
Like that great philosopher once said, "It is when we lose site of
our past that we become the estranged elite."
-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/
10. Re: Random Password
Alex Blanchette wrote:
>
> Thank you everyone for your gracious help, I admit I was a bit skeptical about
> asking for help on a forum due to the fact that most forums have those "3l337"
> people that will "Flame" you for asking anything related to beginners level
> of work.
I think that's only the Perl groups - at least, that has been my
experience ;)
Irv
11. Re: Random Password
LOL..I had the same experience in a Perl group...so I flamed 'em right
back.....told 'em how much better the euphoria group was..and then promptly
unsubscribed from the group...heh..i don't need Perl that bad.
Michelle Rogers
----- Original Message -----
From: "irv mullins" <guest at RapidEuphoria.com>
To: <EUforum at topica.com>
Sent: Friday, July 30, 2004 4:52 PM
Subject: Re: Random Password
>
>
> posted by: irv mullins <irvm at ellijay.com>
>
> Alex Blanchette wrote:
> >
> > Thank you everyone for your gracious help, I admit I was a bit skeptical
about
> > asking for help on a forum due to the fact that most forums have those
"3l337"
> > people that will "Flame" you for asking anything related to beginners
level
> > of work.
>
> I think that's only the Perl groups - at least, that has been my
> experience ;)
>
> Irv
>
>
>
>
12. Re: Random Password
heh..thing was.......it was a BEGINNERS Perl group. *smirks*
Michelle Rogers
----- Original Message -----
From: "Michelle Rogers" <michellerogers at bellsouth.net>
To: <EUforum at topica.com>
Sent: Friday, July 30, 2004 9:52 PM
Subject: Re: Random Password
>
>
> LOL..I had the same experience in a Perl group...so I flamed 'em right
> back.....told 'em how much better the euphoria group was..and then
promptly
> unsubscribed from the group...heh..i don't need Perl that bad.
>
>
> Michelle Rogers
> ----- Original Message -----
> From: "irv mullins" <guest at RapidEuphoria.com>
> To: <EUforum at topica.com>
> Sent: Friday, July 30, 2004 4:52 PM
> Subject: Re: Random Password
>
>
> > posted by: irv mullins <irvm at ellijay.com>
> >
> > Alex Blanchette wrote:
> > >
> > > Thank you everyone for your gracious help, I admit I was a bit
skeptical
> about
> > > asking for help on a forum due to the fact that most forums have those
> "3l337"
> > > people that will "Flame" you for asking anything related to beginners
> level
> > > of work.
> >
> > I think that's only the Perl groups - at least, that has been my
> > experience ;)
> >
> > Irv
> >
> >
>
>
>
13. Re: Random Password
Michelle Rogers wrote:
> heh..thing was.......it was a BEGINNERS Perl group. *smirks*
> Michelle Rogers
Like, 'knit one, perl one'?
14. Re: Random Password
Michelle Rogers wrote:
>
> LOL..I had the same experience in a Perl group...so I flamed 'em right
> back.....told 'em how much better the euphoria group was..and then promptly
> unsubscribed from the group...heh..i don't need Perl that bad.
I even got a personal (and somewhat arrogant) e-mail from Larry Wall.
Unfortunately, he didn't supply a valid reply address. I guess
he wasn't actually interested in debating anything.
Irv
15. Re: Random Password
I guess he meant l337 (leet).
On Fri, 30 Jul 2004 23:11:35 -0300
Ricardo Forno <rforno at uyuyuy.com> wrote:
>
>
> "3l337"?? What does it mean??
>
> ----- Original Message -----
> From: Alex Blanchette <guest at RapidEuphoria.com>
> To: <EUforum at topica.com>
> Sent: Friday, July 30, 2004 4:40 PM
> Subject: Re: Random Password
>
>
> > posted by: Alex Blanchette <caithman at juno.com>
> >
> > Thank you everyone for your gracious help, I admit I was a bit skeptical
> about
> > asking for help on a forum due to the fact that most forums have those
> "3l337"
> > people that will "Flame" you for asking anything related to beginners
> level
> > of work.
> >
> > Thy name is but a short lived word,
> > Thy life is a forever ending story...
> >
> >
16. Re: Random Password
Guillermo Bonvehi wrote:
>
> I guess he meant l337 (leet).
Which is short for "elite."
Check it out: http://en.wikipedia.org/wiki/Leet
-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/