Throw exception if neither openssl nor mcrypt is available

This commit is contained in:
Kijin Sung 2018-12-03 15:10:20 +09:00
parent 75a468552d
commit 4b6737800f
3 changed files with 18 additions and 2 deletions

View file

@ -64,7 +64,14 @@ class Security
}
// Otherwise, use the CryptoCompat class.
return base64_encode(\CryptoCompat::encrypt($plaintext, $key));
if (function_exists('mcrypt_encrypt'))
{
return base64_encode(\CryptoCompat::encrypt($plaintext, $key));
}
else
{
throw new Exception('msg_crypto_not_available');
}
}
/**
@ -102,7 +109,14 @@ class Security
}
// Otherwise, use the CryptoCompat class.
return \CryptoCompat::decrypt($ciphertext, $key);
if (function_exists('mcrypt_decrypt'))
{
return \CryptoCompat::decrypt($ciphertext, $key);
}
else
{
throw new Exception('msg_crypto_not_available');
}
}
/**