00001 #include "strutils.h" 00002 #ifdef ISLINUX 00003 #include <crypt.h> 00004 #endif 00005 00006 #include <unistd.h> 00007 #include <stdlib.h> 00008 00009 WvString passwd_crypt(const char *str) 00010 { 00011 static char saltchars[] = 00012 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; 00013 char salt[3], *result; 00014 00015 salt[0] = saltchars[random() % (sizeof(saltchars) - 1)]; 00016 salt[1] = saltchars[random() % (sizeof(saltchars) - 1)]; 00017 salt[2] = 0; 00018 00019 result = crypt(str, salt); 00020 if (!result) 00021 return "*"; 00022 00023 WvString s(result); 00024 s.unique(); 00025 return s; 00026 }