/**
* Encrypt the data
*
* @param string $plainText Plaintext data
* @param string $key Encryption key
* @param string $iv IV for the encryption
*
* @return string Encrypted data
*/
public function encrypt($plainText, $key, $iv = null)
{
$iv_size = $this->getBlockSize();
$key = $this->resizeKey($key, $iv_size);
$iv = $this->resizeKey($iv, $iv_size);
if (empty($iv)) {
$randVal = new Randval();
$iv = $randVal->generate($iv_size);
}
$cipherText = mcrypt_encrypt($this->cipherType, $key, $plainText, $this->cipherMode, $iv);
$cipherText = $iv . $cipherText;
return $cipherText;
}