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