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