Thread: help me please

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    1

    Unhappy help me please

    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

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Try a PHP board.

  3. #3
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    I don't see what you're having trouble with. PHP is basically C with dynamic typing. I haven't done PHP for some time but it wouldn't surprise if you would get a working implementation just by stripping away the type information.

Popular pages Recent additions subscribe to a feed