您的位置:首页 > 编程语言 > PHP开发

php 与 CPP 共用aes,ecb模式加密

2011-02-21 17:28 951 查看
代码地址
http://www.phpaes.com
经验证,和cpp得到的加密串一致。

 

 

aes,选择ecb模式

 

 

使用例子

 

 

<?php
include("./AES.class.php");
$z = "abcdefgh01234567"; // 128-bit key
//$z = "abcdefghijkl012345678901"; // 192-bit key
//$z = "abcdefghijuklmno0123456789012345"; // 256-bit key
$aes = new AES($z);
//$data = file_get_contents("./example.txt");
//$data = 'hellohellohellohellohello';
$data = 'hello';
$data = app_get_sessionkey(111,222);
$start = microtime(true);
echo "/n/nkey:/n" . $z. "/n";
echo "/n/nCipher-Text:/n" . bin2hex($aes->encrypt($data)) . "/n";
echo "/n/nPlain-Text:/n" . $aes->decrypt($aes->encrypt($data)) . "/n";
$end = microtime(true);
echo "/n/nExecution time: " . ($end - $start);
function app_get_sessionkey($appId, $channelId) {
$ret	= Array(
'appId' => $appId
,'channelId' => $channelId
,'time' => time()

);
$ret	= json_encode($ret);
return $ret;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  加密 php function hex json file