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