Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- * Tiny Encryption Algorithm for PHP Version 1.1
- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
- class TeaCrypt {
- function tea_convert_u($x,$h,$l) {
- if($x>=0){
- $h=(int)($x/65536)&0xffff;
- $l=(int)($x-$h*65536)&0xffff;
- }
- else{
- while(($x=4294967296+$x)<0);// 2^32
- $h=(int)($x/65536)&0xffff;
- $l=(int)($x-$h*65536)&0xffff;
- }
- }
- function tea_xor($ax, $bx) {
- if (PHP_OS=="WINNT" || PHP_INT_SIZE==8) return $ax^$bx;
- /* for 32bit-unix */
- $ah=0;
- $al=0;
- $bh=0;
- $bl=0;
- $bl=0;
- //$ax=$ax&0xffffffff;
- //$bx=$bx&0xffffffff;
- //if(PHP_INT_SIZE==8)
- //return $ax^$bx;
- $this->tea_convert_u($ax,&$ah,&$al);
- $this->tea_convert_u($bx,&$bh,&$bl);
- return (($ah^$bh)*65536)|($al^$bl);
- }
- function tea_add($ax, $bx) {
- $eax=$ax+$bx;
- if ($eax>4294967296) $eax-=4294967296;//2^32
- return $eax;
- }
- function tea_dec($ax, $bx) {
- $eax=$ax-$bx;
- if ($eax<0) $eax+=4294967296;//2^32
- return $eax;
- }
- function tea_left($ax, $bit) {
- $eax=$ax<<$bit;
- if ($eax>4294967296) $eax=$eax%4294967296;//2^32
- return $eax;
- }
- function tea_right($ax, $bit) {
- $eax=$ax>>$bit;
- if ($eax<0) $eax=$eax%4294967296;//2^32
- return $eax;
- }
- function GetRandomKey() {
- mt_srand((double)microtime() * 1000000);
- $zMD5=md5(mt_rand(0, 99999999));
- $string="";
- for ($i=0;$i<16;$i++) {
- $string.=chr(HexDec(substr($zMD5,$i*2,2)));
- }
- return $string;
- }
- function Hex2Dec($HEX) {
- $HEX_ARRAY=array();
- $HEX_ARRAY[0]=DecHex(ord($HEX[0]));
- $HEX_ARRAY[1]=DecHex(ord($HEX[1]));
- $HEX_ARRAY[2]=DecHex(ord($HEX[2]));
- $HEX_ARRAY[3]=DecHex(ord($HEX[3]));
- if (strlen($HEX_ARRAY[0])<2) $HEX_ARRAY[0]="0".$HEX_ARRAY[0];
- if (strlen($HEX_ARRAY[1])<2) $HEX_ARRAY[1]="0".$HEX_ARRAY[1];
- if (strlen($HEX_ARRAY[2])<2) $HEX_ARRAY[2]="0".$HEX_ARRAY[2];
- if (strlen($HEX_ARRAY[3])<2) $HEX_ARRAY[3]="0".$HEX_ARRAY[3];
- $DEC=HexDec($HEX_ARRAY[0].$HEX_ARRAY[1].$HEX_ARRAY[2].$HEX_ARRAY[3]);
- return $DEC;
- }
- function Dec2Hex($DEC) {
- $HEX=DecHex($DEC);
- $len=strlen($HEX);
- if ($len<8) {
- $bad=8-$len;
- for ($i=0;$i<$bad;$i++) {
- $HEX="0".$HEX;
- }
- }
- $HEX_ARRAY=array();
- $HEX_ARRAY[0]=$HEX[0].$HEX[1];
- $HEX_ARRAY[1]=$HEX[2].$HEX[3];
- $HEX_ARRAY[2]=$HEX[4].$HEX[5];
- $HEX_ARRAY[3]=$HEX[6].$HEX[7];
- return chr(HexDec($HEX_ARRAY[0])).chr(HexDec($HEX_ARRAY[1])).chr(HexDec($HEX_ARRAY[2])).chr(HexDec($HEX_ARRAY[3]));
- }
- function cs_rand() {
- return 0xdead;
- return rand(0, 0xffff);
- }
- function teaEncipher($v,$k) {
- $va=$v[0].$v[1].$v[2].$v[3];
- $vb=$v[4].$v[5].$v[6].$v[7];
- $ka=$k[0].$k[1].$k[2].$k[3];
- $kb=$k[4].$k[5].$k[6].$k[7];
- $kc=$k[8].$k[9].$k[10].$k[11];
- $kd=$k[12].$k[13].$k[14].$k[15];
- $y_a=0;
- $y_b=0;
- $y_c=0;
- $z_a=0;
- $z_b=0;
- $z_c=0;
- $tmp_y=0;
- $tmp_z=0;
- //unsigned int
- $y = $this->Hex2Dec($va);
- $z = $this->Hex2Dec($vb);
- $a = $this->Hex2Dec($ka);
- $b = $this->Hex2Dec($kb);
- $c = $this->Hex2Dec($kc);
- $d = $this->Hex2Dec($kd);
- $n = 0x10; /* do encrypt 16 (0x10) times */
- $sum = 0;
- $delta = 0x9E3779B9; /* 0x9E3779B9 - 0x100000000 = -0x61C88647 */
- //unsigned int max value is 4294967295
- while ($n-- > 0) {
- if (PHP_OS=="WINNT" || PHP_INT_SIZE==4) {
- $sum = $sum + $delta;
- $tmp_y = $this->tea_xor($this->tea_xor((($z << 4) + $a) , ($z + $sum)) , (($z/32) + $b));
- $y = BinDec(DecBin($y + $tmp_y));
- $tmp_z = $this->tea_xor($this->tea_xor((($y << 4) + $c) , ($y + $sum)) , (($y/32) + $d));
- $z = BinDec(DecBin($z + $tmp_z));
- }
- else {
- $sum = $this->tea_add($sum, $delta);
- $ya = $this->tea_add($this->tea_left($z, 4) , $a);
- $yb = $this->tea_add($z , $sum);
- $yc = $this->tea_add($this->tea_right($z , 5) , $b);
- $tmp_y = $this->tea_xor($this->tea_xor($ya , $yb) , $yc);
- $y = $this->tea_add($y , $tmp_y);
- $za = $this->tea_add($this->tea_left($y, 4) , $c);
- $zb = $this->tea_add($y , $sum);
- $zc = $this->tea_add($this->tea_right($y , 5) , $d);
- $tmp_z = $this->tea_xor($this->tea_xor($za , $zb) , $zc);
- $z = $this->tea_add($z , $tmp_z);
- }
- }
- $w=$this->Dec2Hex($y).$this->Dec2Hex($z);
- return $w;
- }
- function teaDecipher($v,$k) {
- $va=$v[0].$v[1].$v[2].$v[3];
- $vb=$v[4].$v[5].$v[6].$v[7];
- $ka=$k[0].$k[1].$k[2].$k[3];
- $kb=$k[4].$k[5].$k[6].$k[7];
- $kc=$k[8].$k[9].$k[10].$k[11];
- $kd=$k[12].$k[13].$k[14].$k[15];
- $y_a=0;
- $y_b=0;
- $y_c=0;
- $z_a=0;
- $z_b=0;
- $z_c=0;
- $tmp_y=0;
- $tmp_z=0;
- //unsigned int
- $y = $this->Hex2Dec($va);
- $z = $this->Hex2Dec($vb);
- $a = $this->Hex2Dec($ka);
- $b = $this->Hex2Dec($kb);
- $c = $this->Hex2Dec($kc);
- $d = $this->Hex2Dec($kd);
- $n = 0x10;
- $sum = 0xE3779B90;
- $delta = 0x9E3779B9; /* why this ? must be related with n value*/
- /* sum = delta<<5, in general sum = delta * n */
- while ($n-- > 0) {
- if (PHP_OS=="WINNT" || PHP_INT_SIZE==4) {
- $tmp_z = $this->tea_xor($this->tea_xor((($y << 4) + $c) , ($y + $sum)) , (($y/32) + $d));
- $z = BinDec(DecBin($z - $tmp_z));
- $tmp_y = $this->tea_xor($this->tea_xor((($z << 4) + $a) , ($z + $sum)) , (($z/32) + $b));
- $y = BinDec(DecBin($y - $tmp_y));
- $sum = $sum - $delta;
- }
- else {
- $za = $this->tea_add($this->tea_left($y , 4) , $c);
- $zb = $this->tea_add($y , $sum);
- $zc = $this->tea_add($this->tea_right($y , 5) , $d);
- $tmp_z = $this->tea_xor($this->tea_xor($za , $zb) , $zc);
- $z = $this->tea_dec($z , $tmp_z);
- $ya = $this->tea_add($this->tea_left($z , 4) , $a);
- $yb = $this->tea_add($z , $sum);
- $yc = $this->tea_add($this->tea_right($z , 5) , $b);
- $tmp_y = $this->tea_xor($this->tea_xor($ya , $yb) , $yc);
- $y = $this->tea_dec($y , $tmp_y);
- $sum = $this->tea_dec($sum , $delta);
- }
- }
- $w=$this->Dec2Hex($y).$this->Dec2Hex($z);
- return $w;
- }
- function encrypt($instr,$key) {
- $xx=0;//while counter
- $outstr=array();
- $instrlen=strlen($instr);
- $plain=array(8); /* plain text buffer*/
- $plain_pre_8=array(8); /* plain text buffer, previous 8 bytes*/
- $zcrypted=array(8); /* crypted text*/
- $crypted_pre_8=array(8); /* crypted test, previous 8 bytes*/
- $pos_in_byte = 1; /* loop in the byte */
- $is_header=1; /* header is one byte*/
- $count=0; /* number of bytes being crypted*/
- $padding = 0; /* number of padding stuff*/
- $pos_in_byte = ($instrlen + 0x0a) % 8; /* header padding decided by instrlen*/
- if ($pos_in_byte) {
- $pos_in_byte = 8 - $pos_in_byte;
- }
- $plain[0] = chr(($this->cs_rand() & 0xf8) | $pos_in_byte);
- //memset(plain+1, $this->cs_rand()&0xff, pos_in_byte++);
- //memset(plain_pre_8, 0x00, sizeof(plain_pre_8));
- $xval=chr($this->cs_rand() & 0xff);
- for ($xx=0;$xx<$pos_in_byte;$xx++) {
- $plain[$xx+1]=$xval;
- }
- $pos_in_byte++;
- for ($xx=0;$xx<8;$xx++) {
- $plain_pre_8[$xx]="\x00";
- }
- $padding = 1; /* pad some stuff in header*/
- while ($padding <= 2) { /* at most two byte */
- if($pos_in_byte < 8) {
- $plain[$pos_in_byte++] = chr($this->cs_rand() & 0xff);
- $padding++;
- }
- if($pos_in_byte == 8) {
- //encrypt_every_8_byte();
- /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
- /*** we encrypt every eight byte ***/
- for ($pos_in_byte=0; $pos_in_byte<8; $pos_in_byte++) {
- if($is_header) {
- $plain[$pos_in_byte] = chr(ord($plain[$pos_in_byte]) ^ ord($plain_pre_8[$pos_in_byte]));
- }
- else {
- $plain[$pos_in_byte] = chr(ord($plain[$pos_in_byte]) ^ ord($crypted_pre_8[$pos_in_byte]));
- }
- }/* prepare plain text*/
- for ($xx=0;$xx<8;$xx++) {
- $zcrypted[$xx]="\x00";
- }
- //(unsigned int *)plain
- //(unsigned int *)key
- //(unsigned int *)zcrypted
- $zcrypted=$this->teaEncipher($plain,$key); /* encrypt it*/
- $tmp_zcrypted=array();
- for ($xx=0;$xx<8;$xx++) {
- $tmp_zcrypted[$xx]=$zcrypted[$xx];
- }
- for($pos_in_byte=0; $pos_in_byte<8; $pos_in_byte++) {
- $tmp_zcrypted[$pos_in_byte] = chr(ord($tmp_zcrypted[$pos_in_byte]) ^ ord($plain_pre_8[$pos_in_byte]));
- }
- for ($xx=0;$xx<8;$xx++) {
- $zcrypted[$xx]=$tmp_zcrypted[$xx];
- }
- for ($xx=0;$xx<8;$xx++) {
- $plain_pre_8[$xx]=$plain[$xx];
- }
- for ($xx=0;$xx<8;$xx++) {
- $crypted_pre_8[$xx] = $zcrypted[$xx];
- }
- for ($xx=0;$xx<8;$xx++) {
- $outstr[$count+$xx]=$zcrypted[$xx];
- }
- $count += 8; /* outstrlen increase by 8*/
- $pos_in_byte = 0;
- $is_header = 0; /* and exit header*/
- /* encrypt_every_8_byte*/
- /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
- }
- }
- $inp_c=0;
- while ($instrlen > 0) {
- if ($pos_in_byte < 8) {
- $plain[$pos_in_byte++] = $instr[$inp_c++];
- $instrlen--;
- }
- if ($pos_in_byte == 8) {
- //encrypt_every_8_byte();
- /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
- /*** we encrypt every eight byte ***/
- for ($pos_in_byte=0; $pos_in_byte<8; $pos_in_byte++) {
- if($is_header) {
- $plain[$pos_in_byte] = chr(ord($plain[$pos_in_byte]) ^ ord($plain_pre_8[$pos_in_byte]));
- }
- else {
- $plain[$pos_in_byte] = chr(ord($plain[$pos_in_byte]) ^ ord($crypted_pre_8[$pos_in_byte]));
- }
- }/* prepare plain text*/
- for ($xx=0;$xx<8;$xx++) {
- $zcrypted[$xx]="\x00";
- }
- //(unsigned int *)plain
- //(unsigned int *)key
- //(unsigned int *)zcrypted
- $zcrypted=$this->teaEncipher($plain,$key); /* encrypt it*/
- $tmp_zcrypted=array();
- for ($xx=0;$xx<8;$xx++) {
- $tmp_zcrypted[$xx]=$zcrypted[$xx];
- }
- for($pos_in_byte=0; $pos_in_byte<8; $pos_in_byte++) {
- $tmp_zcrypted[$pos_in_byte] = chr(ord($tmp_zcrypted[$pos_in_byte]) ^ ord($plain_pre_8[$pos_in_byte]));
- }
- for ($xx=0;$xx<8;$xx++) {
- $zcrypted[$xx]=$tmp_zcrypted[$xx];
- }
- for ($xx=0;$xx<8;$xx++) {
- $plain_pre_8[$xx]=$plain[$xx];
- }
- for ($xx=0;$xx<8;$xx++) {
- $crypted_pre_8[$xx] = $zcrypted[$xx];
- }
- for ($xx=0;$xx<8;$xx++) {
- $outstr[$count+$xx]=$zcrypted[$xx];
- }
- $count += 8; /* outstrlen increase by 8*/
- $pos_in_byte = 0;
- $is_header = 0; /* and exit header*/
- /* encrypt_every_8_byte*/
- /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
- }
- }
- $padding = 1; /* pad some stuff in tailer*/
- while ($padding <= 7) { /* at most sever byte*/
- if ($pos_in_byte < 8) {
- $plain[$pos_in_byte++] = "\x00";
- $padding++;
- }
- if ($pos_in_byte == 8) {
- //encrypt_every_8_byte();
- /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
- /*** we encrypt every eight byte ***/
- for ($pos_in_byte=0; $pos_in_byte<8; $pos_in_byte++) {
- if($is_header) {
- $plain[$pos_in_byte] = chr(ord($plain[$pos_in_byte]) ^ ord($plain_pre_8[$pos_in_byte]));
- }
- else {
- $plain[$pos_in_byte] = chr(ord($plain[$pos_in_byte]) ^ ord($crypted_pre_8[$pos_in_byte]));
- }
- }/* prepare plain text*/
- for ($xx=0;$xx<8;$xx++) {
- $zcrypted[$xx]="\x00";
- }
- //(unsigned int *)plain
- //(unsigned int *)key
- //(unsigned int *)zcrypted
- $zcrypted=$this->teaEncipher($plain,$key); /* encrypt it*/
- $tmp_zcrypted=array();
- for ($xx=0;$xx<8;$xx++) {
- $tmp_zcrypted[$xx]=$zcrypted[$xx];
- }
- for($pos_in_byte=0; $pos_in_byte<8; $pos_in_byte++) {
- $tmp_zcrypted[$pos_in_byte] = chr(ord($tmp_zcrypted[$pos_in_byte]) ^ ord($plain_pre_8[$pos_in_byte]));
- }
- for ($xx=0;$xx<8;$xx++) {
- $zcrypted[$xx]=$tmp_zcrypted[$xx];
- }
- for ($xx=0;$xx<8;$xx++) {
- $plain_pre_8[$xx]=$plain[$xx];
- }
- for ($xx=0;$xx<8;$xx++) {
- $crypted_pre_8[$xx] = $zcrypted[$xx];
- }
- for ($xx=0;$xx<8;$xx++) {
- $outstr[$count+$xx]=$zcrypted[$xx];
- }
- $count += 8; /* outstrlen increase by 8*/
- $pos_in_byte = 0;
- $is_header = 0; /* and exit header*/
- /* encrypt_every_8_byte*/
- /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
- }
- }
- //*outstrlen_ptr=count;/* everything is ok! set return string length*/
- return implode('',$outstr);
- }
- function decrypt($instr,$key) {
- $xx=0;//while counter
- $zcrypt_buff_c=0;
- $outstr=array();
- $instrlen=strlen($instr);
- $decrypted=array(8);
- $m[8]=array(8);
- $zcrypt_buff=array(8);
- $crypt_buff_pre_8=array(8);
- $bNeedRet=false;
- $count=0;
- $context_start=0;
- $pos_in_byte=0;
- $padding=0;
- /* at least 16 bytes and %8 == 0*/
- if (($instrlen % 8) || ($instrlen < 16)) return;
- /* get information from header*/
- $decrypted=$this->teaDecipher($instr,$key);
- $pos_in_byte = ord($decrypted[0]) & 0x7;
- $count = $instrlen - $pos_in_byte - 10; /* this is the plaintext length*/
- /* return if outstr buffer is not large enought or error plaintext length*/
- if ($count < 0) return;
- for ($xx=0;$xx<8;$xx++) {
- $m[$xx]="\x00";
- $crypt_buff_pre_8[$xx]="\x00";
- }
- //*outstrlen_ptr = count; /* everything is ok! set return string length*/
- $zcrypt_buff_c+=8;
- for ($xx=0;$xx<8;$xx++) {
- $zcrypt_buff[$xx]=$instr[$zcrypt_buff_c+$xx];
- }
- $context_start = 8; /* context is at the second 8 byte*/
- $pos_in_byte++; /* start of paddng stuffv*/
- $padding = 1; /* at least one in header*/
- while ($padding <= 2) { /* there are 2 byte padding stuff in header*/
- if ($pos_in_byte < 8) { /* bypass the padding stuff, none sense data*/
- $pos_in_byte++;
- $padding++;
- }
- if ($pos_in_byte == 8) {
- for ($xx=0;$xx<8;$xx++) {
- $crypt_buff_pre_8[$xx]=$instr[$xx];
- }
- /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
- $bNeedRet = false;
- for ($pos_in_byte = 0; $pos_in_byte < 8; $pos_in_byte++) {
- if ($context_start + $pos_in_byte >= $instrlen) {
- $bNeedRet = true;
- break;
- }
- $decrypted[$pos_in_byte] = chr(ord($decrypted[$pos_in_byte]) ^ ord($zcrypt_buff[$pos_in_byte]));
- }
- if(!$bNeedRet) {
- $decrypted=$this->teaDecipher($decrypted,$key);
- $context_start += 8;
- $zcrypt_buff_c+=8;
- for ($xx=0;$xx<8;$xx++) {
- // @@
- $_t=$zcrypt_buff_c+$xx;
- $_t>=strlen($instr) ? $_t=strlen($instr)-1 : "";
- $zcrypt_buff[$xx]=$instr[$_t];
- }
- $pos_in_byte = 0;
- }
- /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
- }
- }
- $outp_c=0;
- while($count !=0) {
- if ($pos_in_byte < 8) {
- $outstr[$outp_c++] = chr(ord($crypt_buff_pre_8[$pos_in_byte]) ^ ord($decrypted[$pos_in_byte]));
- $count--;
- $pos_in_byte++;
- }
- if ($pos_in_byte == 8) {
- for($xx=0;$xx<8;$xx++)
- {
- $crypt_buff_pre_8[$xx]=$instr[$zcrypt_buff_c-8+$xx];
- }
- /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
- $bNeedRet = false;
- for ($pos_in_byte = 0; $pos_in_byte < 8; $pos_in_byte++) {
- if ($context_start + $pos_in_byte >= $instrlen) {
- $bNeedRet = true;
- break;
- }
- $decrypted[$pos_in_byte] = chr(ord($decrypted[$pos_in_byte]) ^ ord($zcrypt_buff[$pos_in_byte]));
- }
- if(!$bNeedRet) {
- $decrypted=$this->teaDecipher($decrypted,$key);
- $context_start += 8;
- $zcrypt_buff_c+=8;
- for ($xx=0;$xx<8;$xx++) {
- $zcrypt_buff_i=($zcrypt_buff_c+$xx>=$instrlen) ? "\x00" : $instr[$zcrypt_buff_c+$xx];//here may bigger
- $zcrypt_buff[$xx]=$zcrypt_buff_i;
- }
- $pos_in_byte = 0;
- }
- /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
- }
- }
- for ($padding = 1; $padding < 8; $padding ++) {
- if ($pos_in_byte < 8) {
- if (ord($crypt_buff_pre_8[$pos_in_byte]) ^ ord($decrypted[$pos_in_byte])) return;
- $pos_in_byte++;
- }
- if ($pos_in_byte == 8 ) {
- for ($xx=0;$xx<8;$xx++) {
- $crypt_buff_pre_8[$xx]=$zcrypt_buff[$xx];
- }
- /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
- $bNeedRet = false;
- for ($pos_in_byte = 0; $pos_in_byte < 8; $pos_in_byte++) {
- if ($context_start + $pos_in_byte >= $instrlen) {
- $bNeedRet = true;
- break;
- }
- $decrypted[$pos_in_byte] = chr(ord($decrypted[$pos_in_byte]) ^ ord($zcrypt_buff[$pos_in_byte]));
- }
- if(!$bNeedRet) {
- $decrypted=$this->teaDecipher($decrypted,$key);
- $context_start += 8;
- $zcrypt_buff_c+=8;
- for ($xx=0;$xx<8;$xx++) {
- $zcrypt_buff[$xx]=$instr[$zcrypt_buff_c+$xx];
- }
- $pos_in_byte = 0;
- }
- /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
- }
- }
- return implode('',$outstr);
- }
- }
- //¾û
- $tcrypt=new TeaCrypt();
- $e=$tcrypt->encrypt("ÎÒ","1234567890abcdef");
- $d=$tcrypt->decrypt($e,"1234567890abcdef");
- echo "PHP_INT_SIZE=".PHP_INT_SIZE;
- echo "<br>";
- echo base64_encode($e);
- echo "<br>";
- echo $d;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment