protected static function key($password, $iv, $cost, $cipher = 'rijndael-128', $mode = 'cbc', $algo = 'sha256')
{
// This if statement allows the usage of the Openssl library without
// the need to have the mcrypt plugin installed at all.
if ($cipher === 'rijndael-128') {
$keysize = 32;
} else {
$keysize = \mcrypt_get_key_size($cipher, $mode);
}
// Perform key derivation
$key = Hash::ihmac($iv . $cipher . $mode, $password, $cost, $algo);
// Return hash normalized to key length
return self::hashNormalize($key, $keysize, $algo);
}