コード例 #1
0
 protected function getModuleData($moduleName)
 {
     $xxtea = new XXTEA();
     $xxtea->setKey($this->config['key']);
     $srcPath = $this->config['srcpath'] . DS . $moduleName;
     $bytes = file_get_contents($srcPath);
     $bytes = $this->config['sign'] . $xxtea->encrypt($bytes);
     return $bytes;
 }
コード例 #2
0
ファイル: index.php プロジェクト: TunnelBlanket/ASCrypt
//
print "ARC4 otv encrypted is ok: " . bool_str(Base16::encode($arc4tve) == "75b7878099e0c596") . "<br/>\n";
print "ARC4 otv decrypted is ok: " . bool_str(Base16::encode($arc4tvd) == "0123456789abcdef") . "<br/>\n";
print "ARC4 encrypted in UTF-8: " . Base16::encode($arc4e) . "<br/>\n";
print "ARC4 decrypted in UTF-8: " . $arc4d . "<br/><br/>\n";
/**
* Test XXTEA with one official test vector and custom input.
* Vectors from: http://www.crypt.co.za/post/27
*/
$xxttvk = Base16::decode("9e3779b99b9773e9b979379e6b695156");
$xxttvt = Base16::decode("0102040810204080fffefcf8f0e0c080");
$xxttve = XXTEA::encrypt($xxttvk, $xxttvt);
$xxttvd = XXTEA::decrypt($xxttvk, $xxttve);
//
$xxteak = "1234567890123456";
$xxteae = XXTEA::encrypt($xxteak, PKCS7::pad($input, 4));
// Needs padding.
$xxtead = PKCS7::unpad(XXTEA::decrypt($xxteak, $xxteae));
// Needs unpadding.
//
print "XXTEA otv encrypted is ok: " . bool_str(Base16::encode($xxttve) == "01b815fd2e4894d13555da434c9d868a") . "<br/>\n";
print "XXTEA otv decrypted is ok: " . bool_str(Base16::encode($xxttvd) == "0102040810204080fffefcf8f0e0c080") . "<br/>\n";
print "XXTEA encrypted in UTF-8: " . Base16::encode($xxteae) . "<br/>\n";
print "XXTEA decrypted in UTF-8: " . $xxtead . "<br/><br/>\n";
/**
* Test AES-128 with one official test vector and custom input.
* Vectors from: http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf
*/
$aes128tvk = pack("c*", 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf);
$aes128tvt = pack("c*", 0x0, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff);
$aes128tve = AES::encrypt($aes128tvk, $aes128tvt);
コード例 #3
0
 protected function createOutputZIP(array $modules, array $bytes)
 {
     // create ZIP archive
     $zipfile = $this->config['output'];
     $zip = new ZipArchive();
     if (!$zip->open($zipfile, ZIPARCHIVE::OVERWRITE | ZIPARCHIVE::CM_STORE)) {
         return false;
     }
     if (!$this->config['quiet']) {
         printf("create ZIP archive file: %s\n", $zipfile);
     }
     foreach ($modules as $path => $module) {
         $zip->addFromString($this->config['prefix'] . $module['moduleName'], $bytes[$path]);
     }
     $zip->close();
     if ($this->config['encrypt'] == self::ENCRYPT_XXTEA_ZIP) {
         $xxtea = new XXTEA();
         $xxtea->setKey($this->config['key']);
         file_put_contents($zipfile, $this->config['sign'] . $xxtea->encrypt(file_get_contents($zipfile)));
     }
     if (!$this->config['quiet']) {
         printf("done.\n\n");
     }
     return true;
 }
コード例 #4
0
 function xxtea_encrypt($str, $key)
 {
     return XXTEA::encrypt($str, $key);
 }
コード例 #5
0
ファイル: ResEncrypt.php プロジェクト: wuzongan/myproject
 protected function getModulesData(array $modules, $key = null, $sign = null)
 {
     if (!empty($key)) {
         $xxtea = new XXTEA();
         $xxtea->setKey($key);
     }
     $modulesBytes = array();
     foreach ($modules as $path => $module) {
         $bytes = file_get_contents($path);
         if (!empty($key)) {
             $bytes = $sign . $xxtea->encrypt($bytes);
         }
         file_put_contents($module['tempFilePath'], $bytes);
         if (!$bytes) {
             print "\n";
             return false;
         }
         $modulesBytes[$path] = $bytes;
         if (!$this->config['quiet']) {
             printf("  > get bytes [% 3d KB] %s\n", ceil(strlen($bytes) / 1024), $module['moduleName']);
         }
     }
     return $modulesBytes;
 }