11 #define MD5_CRYPT_ENAB yes
15 extern char *crypt (__const char *__key, __const char *__salt);
17 char *crypt_make_salt (void)
20 static char result[40];
23 strcpy (result, "$1$"); /* magic for the new MD5 crypt() */
25 gettimeofday (&tv, (struct timezone *) 0);
26 strcat (result, l64a (tv.tv_usec));
27 strcat (result, l64a (tv.tv_sec + getpid () + clock ()));
29 if (strlen (result) > 3 + 8) result[11] = '\0';
34 char *pw_encrypt (const char *clear, const char *salt)
36 static char cipher[128];
37 char *cp = crypt (clear, salt);
45 /* for new password, we generate salt
46 * for check we use encrypted password as salt
47 * char *crpasswd_or_newsalt = crypt_make_salt();
50 const char* msg = "Enter password:";
53 // clear = "enterclearpasswordhere";
55 if ( !(clear = getpass(msg)) || strlen(clear) == 0 )
57 fprintf (stderr, ("You entered no password \n"));
62 char *crpasswd_or_newsalt = "$1$RG.pRvZh$Q0WZ8clsqtMUBRLFckoQg1";
63 char *cipher = pw_encrypt (clear, crpasswd_or_newsalt);
65 if (strcmp (cipher, crpasswd_or_newsalt) != 0)
67 fprintf (stderr, (crpasswd_or_newsalt));
68 fprintf (stderr, ("\n"));
69 fprintf (stderr, ("Incorrect password. Result is:\n"));
70 fprintf (stderr, (cipher));
71 fprintf (stderr, ("\n"));
76 fprintf (stderr, ("\n"));
77 fprintf (stderr, (crpasswd_or_newsalt));
78 fprintf (stderr, ("\n"));
79 fprintf (stderr, ("Good password\n"));
80 fprintf (stderr, (cipher));
81 fprintf (stderr, ("\n"));