public static function hash($password, array $options = [])
{
if (isset($options['cost']) && ($options['cost'] < 4 || $options['cost'] > 31)) {
throw new Nette\InvalidArgumentException("Cost must be in range 4-31, {$options['cost']} given.");
}
$hash = password_hash($password, PASSWORD_BCRYPT, $options);
if ($hash === FALSE || strlen($hash) < 60) {
throw new Nette\InvalidStateException('Hash computed by password_hash is invalid.');
}
return $hash;
}