コード例 #1
0
ファイル: RC4Test.php プロジェクト: CarsonF/WhatsApi
 public function testChipherMethod()
 {
     $rc4 = new Rc4(hex2bin('7a1fb3b37abe7247af7363e53ddc8aa5964575bc'), 256);
     $res = $rc4->cipher(hex2bin('f80790cb1276fc0654686f6d61734dfc1570726573656e63652d313339313938353938312d32'), 0, 38);
     $this->assertEquals(hex2bin('35be4eb77f495de73d952cc9c910041450114e12efbe1422ac85e021e15d9e26ca7689fea70b'), $res);
 }
コード例 #2
0
ファイル: KeyStream.php プロジェクト: avary/WhatsApi
 /**
  * @param $buffer
  * @param $macOffset
  * @param $offset
  * @param $length
  * @return string
  */
 public function EncodeMessage($buffer, $macOffset, $offset, $length)
 {
     $data = $this->rc4->cipher($buffer, $offset, $length);
     $mac = $this->computeMac($data, $offset, $length);
     return substr($data, 0, $macOffset) . substr($mac, 0, 4) . substr($data, $macOffset + 4);
 }