13    private static function getAlgorithm(
string $algorithmName): string
 
   15        if (!$algorithmName) {
 
   33        if (array_key_exists($algorithmName, $mapping)) {
 
   34            return $mapping[$algorithmName];
 
   37        throw new Exception(
'Unsupported password algorithm: ' . $algorithmName);
 
   55        $chars = preg_split(
'//', $pPassword, -1, PREG_SPLIT_NO_EMPTY);
 
   56        foreach ($chars as $char) {
 
   57            $value = ord($char) << $charPos++; 
 
   58            $rotated_bits = $value >> 15; 
 
   83    public static function hashPassword(
string $password, 
string $algorithm = 
'', 
string $salt = 
'', 
int $spinCount = 10000): string
 
   90        $saltValue = base64_decode($salt);
 
   91        $encodedPassword = mb_convert_encoding(
$password, 
'UCS-2LE', 
'UTF-8');
 
   93        $hashValue = 
hash($phpAlgorithm, $saltValue . $encodedPassword, 
true);
 
   94        for (
$i = 0; 
$i < $spinCount; ++
$i) {
 
   95            $hashValue = 
hash($phpAlgorithm, $hashValue . pack(
'L', 
$i), 
true);
 
   98        return base64_encode($hashValue);
 
An exception for terminatinating execution or to throw for unit testing.
static hashPassword(string $password, string $algorithm='', string $salt='', int $spinCount=10000)
Create a password hash from a given string by a specific algorithm.
static defaultHashPassword(string $pPassword)
Create a password hash from a given string.
static getAlgorithm(string $algorithmName)
Get algorithm name for PHP.
const ALGORITHM_RIPEMD_160
const ALGORITHM_RIPEMD_128
const ALGORITHM_WHIRLPOOL
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.