Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 13.06.2006, 22:11   #1
TuMBLer
Архивный участник
 
Join Date: Apr 2005
Posts: 127
Default php password function

Hello everyone

I have function for encrypt passwords, but it function sometimes encrypt with errors and in client i got Invalid password

Please give to me bug free function for encrypt paswwords.
Thanks.

Code:
//Main function which is encrypting passwords.
function encryptpass($str){
$key = array();
$dst = array();

//bu_String2Bytes
$nBytes = strlen($str);
        while ($i < $nBytes){
                $i++;
                $key[$i] = ord(substr($str, $i - 1, 1));
                $dst[$i] = $key[$i];
        }  

//bu_Bytes2Int
        $rslt = $key[1] + $key[2]*256 + $key[3]*65536 + $key[4]*16777216;
        $one = $rslt * 213119 + 2529077;
        $one = $one - intval($one/ 4294967296) * 4294967296;

        $rslt = $key[5] + $key[6]*256 + $key[7]*65536 + $key[8]*16777216;
        $two = $rslt * 213247 + 2529089;
        $two = $two - intval($two/ 4294967296) * 4294967296;

        $rslt = $key[9] + $key[10]*256 + $key[11]*65536 + $key[12]*16777216;
        $three = $rslt * 213203 + 2529589;
        $three = $three - intval($three/ 4294967296) * 4294967296;

        $rslt = $key[13] + $key[14]*256 + $key[15]*65536 + $key[16]*16777216;
        $four = $rslt * 213821 + 2529997;
        $four = $four - intval($four/ 4294967296) * 4294967296;
//bu_Bytes2Int end

//MyuwSplit
    $key[4] = intval($one/16777216);        
    $key[3] = intval(($one - $key[4] * 16777216) / 65535);
    $key[2] = intval(($one - $key[4] * 16777216 - $key[3] * 65536) / 256);
    $key[1] = intval(($one - $key[4] * 16777216 - $key[3] * 65536 - $key[2] * 256));

    $key[8] = intval($two/16777216);     
    $key[7] = intval(($two - $key[8] * 16777216) / 65535);
    $key[6] = intval(($two - $key[8] * 16777216 - $key[7] * 65536) / 256);
    $key[5] = intval(($two - $key[8] * 16777216 - $key[7] * 65536 - $key[6] * 256));

    $key[12] = intval($three/16777216);     
    $key[11] = intval(($three - $key[12] * 16777216) / 65535);
    $key[10] = intval(($three - $key[12] * 16777216 - $key[11] * 65536) / 256);
    $key[9] = intval(($three - $key[12] * 16777216 - $key[11] * 65536 - $key[10] * 256));

    $key[16] = intval($four/16777216);     
    $key[15] = intval(($four - $key[16] * 16777216) / 65535);
    $key[14] = intval(($four - $key[16] * 16777216 - $key[15] * 65536) / 256);
    $key[13] = intval(($four - $key[16] * 16777216 - $key[15] * 65536 - $key[14] * 256));
//MyuwSplit end

    $dst[1] = $dst[1] ^ $key[1];

       $i=1;
    while ($i<16){
                $i++;
                $dst[$i] = $dst[$i] ^ $dst[$i-1] ^ $key[$i];
        }

        $i=0;
    while ($i<16){
                $i++;
            if ($dst[$i] == 0) {
                        $dst[$i] = 102;
                }
        }

    $encrypt = "0x";
        $i=0;
    while ($i<16){
                $i++;
        if ($dst[$i] < 16) {
            $encrypt = $encrypt . "0" . dechex($dst[$i]);
        } else {
            $encrypt = $encrypt . dechex($dst[$i]);
        }
    }

return $encrypt;
}
TuMBLer is offline  
Old 13.06.2006, 22:53   #2
ateh
Архивный участник
 
Join Date: Apr 2006
Posts: 118
Default

I didn't check yours, but here's function i use:



Code:
function encryptp($str) {
	$key = array();
	$dst = array();
	$i = 0;

	$nBytes = strlen($str);
        	while ($i < $nBytes){
               	 $i++;
                	$key[$i] = ord(substr($str, $i - 1, 1));
                	$dst[$i] = $key[$i];
	}

	$rslt = $key[1] + $key[2]*256 + $key[3]*65536 + $key[4]*16777216;
	$one = $rslt * 213119 + 2529077;
	$one = $one - intval($one/ 4294967296) * 4294967296;

	$rslt = $key[5] + $key[6]*256 + $key[7]*65536 + $key[8]*16777216;
	$two = $rslt * 213247 + 2529089;
	$two = $two - intval($two/ 4294967296) * 4294967296;

	$rslt = $key[9] + $key[10]*256 + $key[11]*65536 + $key[12]*16777216;
	$three = $rslt * 213203 + 2529589;
	$three = $three - intval($three/ 4294967296) * 4294967296;

	$rslt = $key[13] + $key[14]*256 + $key[15]*65536 + $key[16]*16777216;
	$four = $rslt * 213821 + 2529997;
	$four = $four - intval($four/ 4294967296) * 4294967296;

	$key[4] = intval($one/16777216);
	$key[3] = intval(($one - $key[4] * 16777216) / 65536);
	$key[2] = intval(($one - $key[4] * 16777216 - $key[3] * 65536) / 256);
	$key[1] = intval(($one - $key[4] * 16777216 - $key[3] * 65536 - $key[2] * 256));

	$key[8] = intval($two/16777216);
	$key[7] = intval(($two - $key[8] * 16777216) / 65536);
	$key[6] = intval(($two - $key[8] * 16777216 - $key[7] * 65536) / 256);
	$key[5] = intval(($two - $key[8] * 16777216 - $key[7] * 65536 - $key[6] * 256));

	$key[12] = intval($three/16777216);
	$key[11] = intval(($three - $key[12] * 16777216) / 65536);
	$key[10] = intval(($three - $key[12] * 16777216 - $key[11] * 65536) / 256);
	$key[9] = intval(($three - $key[12] * 16777216 - $key[11] * 65536 - $key[10] * 256));

	$key[16] = intval($four/16777216);
	$key[15] = intval(($four - $key[16] * 16777216) / 65536);
	$key[14] = intval(($four - $key[16] * 16777216 - $key[15] * 65536) / 256);
	$key[13] = intval(($four - $key[16] * 16777216 - $key[15] * 65536 - $key[14] * 256));

	$dst[1] = $dst[1] ^ $key[1];

	$i=1;
	while ($i<16){
		$i++;
		$dst[$i] = $dst[$i] ^ $dst[$i-1] ^ $key[$i];
	}

	$i=0;
	while ($i<16){
		$i++;
		if ($dst[$i] == 0) {
			$dst[$i] = 102;
		}
	}

	$encrypt = "0x";
	$i=0;
	while ($i<16){
		$i++;
		if ($dst[$i] < 16) {
			$encrypt = $encrypt . "0" . dechex($dst[$i]);
		} else {
			$encrypt = $encrypt . dechex($dst[$i]);
		}
	}
	$encrypt = strtoupper($encrypt);
	$encrypt[1] = 'x';
	return $encrypt;
}
ateh is offline  
Old 14.06.2006, 07:53   #3
Zeran
Архивный участник
 
Join Date: Mar 2006
Posts: 97
Default

Guys, can you share script for registration, because my not connecting to the database
Zeran is offline  
Old 15.06.2006, 05:57   #4
ateh
Архивный участник
 
Join Date: Apr 2006
Posts: 118
Default

There is php reg script in L2Tools
ateh is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 20:12.