--- a/gpw.c +++ b/gpw.c @@ -13,11 +13,6 @@ and looking for real words in its output.. they are very rare, on the order of one in a thousand. - This program uses "drand48()" to get random numbers, and "srand48()" - to set the seed to the microsecond part of the system clock. Works - for AIX C++ compiler and runtime. Might have to change this to port - to another environment. - The best way to use this program is to generate multiple words. Then pick one you like and transform it with punctuation, capitalization, and other changes to come up with a new password. @@ -35,6 +30,9 @@ /* #include */ /* following for BSD */ #include +#include + +long int pw_random_number(long int max_num); int main (int argc, char ** argv) { int password_length; /* how long should each password be */ @@ -47,14 +45,11 @@ long sum; /* running total of frequencies */ char password[100]; /* buffer to develop a password */ int nchar; /* number of chars in password so far */ - struct timeval systime; /* time reading for random seed */ - struct timezone tz; /* unused arg to gettimeofday */ password_length = 8; /* Default value for password length */ n_passwords = 10; /* Default value for number of pws to generate */ - gettimeofday (&systime, &tz); /* Read clock. */ - srand48 (systime.tv_usec); /* Set random seed. */ + srand48 (pw_random_number(LONG_MAX)); /* Set random seed. */ if (argc > 1) { /* If args are given, convert to numbers. */ n_passwords = atoi (&argv[1][0]);