我一直在尝试加密PHP 5.2中的内容,如下所示:
$key = "12345678901234567890123456789012345678901234567890123456";//56 chars
$iv = "12345678";//8 chars
$text = "Nick is pooping.";//16 chars
$enc = mcrypt_encrypt("blowfish", $key, $text, "cbc", $iv);
var_dump($enc); echo "<br>";
var_dump(base64_encode($enc)); echo "<br>";
这是输出:
string(16) "–±–%ê„zÆtȾ R"
string(24) "lrGWJeofhHrGdMi+BiBSHQ=="
我在iOS上使用this,使用以下代码:
Blowfish* _blowfish = [BlowfishAlgorithm new];
[_blowfish setMode:[BlowfishAlorithm buildModeEnum:@"CBC"]];
[_blowfish setKey:@"12345678901234567890123456789012345678901234567890123456"];
[_blowfish setInitVector:@"12345678"];
[_blowfish setupKey];
NSLog(@"%@",[_blowfish encrypt:@"Nick is pooping."]);
输出:
3132333435363738f61e0c4683e55fe061f1951e7a8182be
base64_encode不能在php中完成这个技巧,我无法弄清楚如何匹配它们以便它们输出相同的内容。 :(
答案 0 :(得分:0)