in reply to (tye)Re: random passgen
in thread random passgen

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.

Replies are listed 'Best First'.
(tye)Re2: random passgen
by tye (Sage) on May 05, 2001 at 08:03 UTC

    ~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")