Last active
September 23, 2016 02:10
-
-
Save Sarav-S/dbc54098677bdb81b0fd65bb55f3cffe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Hash the given value. | |
* | |
* @param string $value | |
* @param array $options | |
* @return string | |
* | |
* @throws \RuntimeException | |
*/ | |
public function make($value, array $options = []) | |
{ | |
$cost = isset($options['rounds']) ? $options['rounds'] : $this->rounds; | |
$hash = password_hash($value, PASSWORD_BCRYPT, ['cost' => $cost]); | |
if ($hash === false) { | |
throw new RuntimeException('Bcrypt hashing not supported.'); | |
} | |
return $hash; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment