Ejemplo n.º 1
0
 public static function encrypt($content, $offset, $key, $times)
 {
     $tempInt = EncryptUtil::bytesToInteger($content, $offset);
     $y = $tempInt[0];
     $z = $tempInt[1];
     $sum = 0;
     $a = $key[0];
     $b = $key[1];
     $c = $key[2];
     $d = $key[3];
     $delta = 0x9e3779b9;
     for ($i = 0; $i < $times; $i++) {
         $sum += $delta;
         $y += ($z << 4) + $a ^ $z + $sum ^ ($z >> 5) + $b;
         $z += ($y << 4) + $c ^ $y + $sum ^ ($y >> 5) + $d;
     }
     $tempInt[0] = $y;
     $tempInt[1] = $z;
     return EncryptUtil::integerToBytes($tempInt, 0);
 }