#include #include /* srand(), rand() */ #include /* time() */ #include /* crypt() */ #include "internal.h" #include "apache.p" static void to64(register char *s, register long v, register int n); char *cryptit (char * pw) { char salt[9]; (void) srand((int) time((time_t *) NULL)); to64(&salt[0], rand(), 8); salt[8] = '\0'; return crypt(pw, salt); } /* from Apache's htpasswd.c */ static void to64(register char *s, register long v, register int n) { static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; while (--n >= 0) { *s++ = itoa64[v & 0x3f]; v >>= 6; } }