Re: generating passwords

2001-05-07 Thread Joe McMahon
On Sat, 5 May 2001, cherukuwada subrahmanyam wrote: > Hi, > Is there any easy way to generate random string of particluar length. > The idea is to generate passwords randomly. Here is some code which produces wordlike passwords via random probes into a dictionary. The results are wordlike, but n

Re: generating passwords

2001-05-05 Thread Jeff Pinyan
On May 5, Jos I Boumans said: > for (0..int(rand(4) + 4)) { > $_ = int(rand(2)); > if (/0/) { > $string .= $letters[rand(26)]; > } else { > $string .= int(rand(10)); > } > } #for This is a silly use of a regex -- it's rather wasteful. Just use: if (int rand 2) { $string .= int ra

Re: generating passwords

2001-05-05 Thread Peter Scott
Here's one that will generate a password exactly 8 characters long composed of two words with a random punctuation character between. (I'd just composed this for someone else.) Substitute an appropriate name of a file of words (one per line, no punctuation) if you don't have /usr/dict/words.

Re: generating passwords

2001-05-05 Thread Jos I Boumans
Here's a little code snippet that might help you on your way this will generate a random pwd of letters and number between 4 and 8 chars. sub usrpwd { #usage $var=usrpwd(); my @letters = ('a'..'z'); my $string; for (0..int(rand(4) + 4)) { $_ = int(rand(2)); if (/0/) { $string .= $lette

Re: generating passwords

2001-05-05 Thread Jeff Pinyan
On May 5, Collin Rogowski said: >rand(123 - 48) + 48: I am glad you used this construct (and even moreso that you explained the mathematics and logic used therein). I have dealt with programmers who used to write simple mIRC scripts, and expect rand(10, 30); to return a number from 10 to 30

Re: generating passwords

2001-05-05 Thread Casey West
On Sat, May 05, 2001 at 12:02:15PM +, cherukuwada subrahmanyam wrote: : Hi, : Is there any easy way to generate random string of particluar length. : The idea is to generate passwords randomly. : I did it using rand function i.e. generating random number and replacing the : number with corres

Re: generating passwords

2001-05-05 Thread Collin Rogowski
This generates passwords consisting of letters (lower and uppercase), numbers and printable punctuation (?,.-_[(, etc.) (ASCII 48 - 122). $required_length = 10; for ($i = 0; $i < $required_length; $i++) { $passwd .= chr(int(rand(123 - 48) + 48)); } print $passwd, "\n"; Discussion: rand(123 -