in reply to random passgen

FYI, you'll get a better seed with srand( rand(~0) ^ $s ^ time ) See Perl's auto srand() RE: a random sort of list for details.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: random passgen
by ashaman (Sexton) on May 05, 2001 at 04:30 UTC
    indeed, it does work better with that. what exactly does the ~0 do, though? i've never seen that before.

    btw, thanks everyone for you help, it works great now.

      ~0 is bit-wise compliment of 0, that is, it gives back an unsigned integer with all bits 1 (since 0 has all bits 0). So rand(~0) gives you a random number between 0 and the largest unsigned integer value. This gives you about 32 bits of randomness from the seed that Perl probably already chose for you to add in with the seed that you chose.

      It should really be rand(1+~0) since the ^ that follows converts to the floating-point value returned by rand() into an unsigned integer which means that the possible values used in the ^ are only from 0..(~0-1).

              - tye (but my friends call me "Tye")