0
我有一个类有以下__construct。mcrypt长时间初始化模块
final class mydecoder {
private $td;
public function __construct($key){
/* Open the cipher */
$this->td = mcrypt_module_open(MCRYPT_BLOWFISH, '', 'ecb', '');
/* Create the IV and determine the keysize length, use MCRYPT_RAND
* on Windows instead */
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->td), MCRYPT_DEV_RANDOM);
$ks = mcrypt_enc_get_key_size($this->td);
/* Create key */
$key = substr(md5($key), 0, $ks);
/* Intialize encryption */
mcrypt_generic_init($this->td, $key, $iv);
}
}
当我这样称呼它:
$encoder = new myfish('mykey1');
$encoder = new myfish('mykey2');
我有以下问题。
开放页首次
construct #1 execution time: 5s
construct #2 execution time: 0s
按F5
construct #1 execution time: 0s
construct #2 execution time: 14s
按F5
construct #1 execution time: 5s
construct #2 execution time: 14s
糖化F5 3次(排队)
construct #1 execution time: 15s
construct #2 execution time: 45s
它看起来像队列?它是如何工作的?也许我没有正确使用它?我没有与密码太多的经验,因为我从来没有:)
所以基本上,使用'MCRYPT_DEV_RANDOM'会使延迟更远,所以随机距离彼此“更远”? – Grzegorz 2014-10-07 10:36:47
下面是我为您找到的更好的解释:http://stackoverflow.com/a/11173861/2332336 – Latheesan 2014-10-07 10:40:09