コード例 #1
0
ファイル: index.php プロジェクト: TunnelBlanket/ASCrypt
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);
// ECB mode, no padding needed.
$aes128tvd = AES::decrypt($aes128tvk, $aes128tve);
コード例 #2
0
 function xxtea_decrypt($str, $key)
 {
     return XXTEA::decrypt($str, $key);
 }