Skip to content

Instantly share code, notes, and snippets.

@Sarav-S
Last active September 23, 2016 02:10
Show Gist options
  • Save Sarav-S/dbc54098677bdb81b0fd65bb55f3cffe to your computer and use it in GitHub Desktop.
Save Sarav-S/dbc54098677bdb81b0fd65bb55f3cffe to your computer and use it in GitHub Desktop.
<?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