[Security] added an exception when the BCrypt encoder cannot be used (refs #7853)

This commit is contained in:
Fabien Potencier 2013-04-26 11:43:22 +02:00
parent d59ffc9aa2
commit aae9afb6d8
1 changed files with 4 additions and 0 deletions

View File

@ -33,6 +33,10 @@ class BCryptPasswordEncoder extends BasePasswordEncoder
*/
public function __construct($cost)
{
if (!function_exists('password_hash')) {
throw new \RuntimeException('To use the BCrypt encoder, you need to upgrade to PHP 5.5 or install the "ircmaxell/password-compat" via Composer.');
}
$cost = (int) $cost;
if ($cost < 4 || $cost > 31) {
throw new \InvalidArgumentException('Cost must be in the range of 4-31.');