/**
* Static method decrypt a field value
*
* @param string $value
* @param int $encryption
* @param array $options
* @return string
*/
public static function decrypt($value, $encryption, $options = array())
{
$decValue = $value;
$salt = !empty($options['salt']) ? $options['salt'] : null;
// Decrypt the value
switch ($encryption) {
case Auth::ENCRYPT_NONE:
$decValue = $value;
break;
case Auth::ENCRYPT_MCRYPT:
$crypt = new Crypt\Mcrypt();
$crypt->setSalt($salt);
// Set cipher, mode and source, if applicable
if (!empty($options['cipher'])) {
$crypt->setCipher($options['cipher']);
}
if (!empty($options['mode'])) {
$crypt->setMode($options['mode']);
}
if (!empty($options['source'])) {
$crypt->setSource($options['source']);
}
$decValue = $crypt->decrypt($value);
break;
default:
$decValue = '[Encrypted]';
}
return $decValue;
}