Code:
static unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static void to64 (char *s, long v, int n)
{
while (--n >= 0) {
*s++ = itoa64[v & 0x3f];
v >>= 6;
}
}
int cmd_chpasswd (user_t *user, const char *old, const char *txtpass)
{
char salt[3];
to64(salt, rand(), 2); /* calculate salt */
user->pass = strdup(crypt(txtpass,salt)); /* crypt password */
return 1;
}
I want to rewrite to64() in PHP but I can't translate it to PHP. Help me please
Thank you