I am having an issue with my cipher class. At times it is very fast. Sometimes however it is slow. the code Im using is as follows
class Cipher {
private $securekey, $iv;
function __construct() {
$this->securekey = hash('sha256','51(^8k"12cJ[6&cvo3H/!2s02Uh46vuT4l7sc7a@cZ27Q',TRUE);
$this->iv = mcrypt_create_iv(32);
}
function encrypt($input) {
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->securekey, $input, MCRYPT_MODE_ECB));
}
function decrypt($input) {
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->securekey, base64_decode($input), MCRYPT_MODE_ECB));
}
function storeIV() {
return $this->iv;
}
}
Are there any suggestions on why this may be slow at times and how I could fix this?