我有一个脚本在文件中调用一个键,我希望将它集成在包含函数的变量中但不起作用
=> keyfile.txt
100,102,52,57,49,51,49,51,48,49,101,102,97,99,49,52,57,56,102,57,53,99,99,49,98,97,57,98,51,48,99,99
集成在php文件中
$open = fopen("php\key\keyfile.txt", "r");
$clef=fgets($open,255);
$td = mcrypt_module_open('rijndael-128', '', 'ecb', '');
$iv = str_repeat("\x00", 16);
$key = pack("C*",$clef); ## **not working**
$key = $key . str_repeat("\x00", 32 - strlen($key));
mcrypt_generic_init($td, $key, $iv);
$key = mcrypt_generic($td, $key);
$key = str_repeat(substr($key, 0, 16), 2);
mcrypt_generic_deinit($td);
我不知道为什么 请帮忙
答案 0 :(得分:0)
PHP就是这样想的:
$key = pack("C*", "100,102...");
而不是:
$key = pack("C*", 100,102,...);
您可以使用call_user_func_array()
获得所需内容:
$chr = "C*";
$int = explode(',', $clef);
$key = call_user_func_array('pack', array_merge(array($chr), $int));