<?php class Password { // these constants may be changed without breaking existing hashes. const PBKDF2_HASH_ALGORITHM = 'sha256'; const PBKDF2_ITERATIONS = 1000; const PBKDF2_SALT_BYTE_SIZE = 24; const PBKDF2_HASH_BYTE_SIZE = 24; const HASH_SECTIONS = 4; const HASH_ALGORITHM_INDEX = 0; const HASH_ITERATION_INDEX = 1; const HASH_SALT_INDEX = 2; const HASH_PBKDF2_INDEX = 3; { // format: algorithm:iterations:salt:hash return self::PBKDF2_HASH_ALGORITHM . ":" . self::PBKDF2_ITERATIONS . ":" . $salt . ":" . self::PBKDF2_HASH_ALGORITHM, $password, $salt, self::PBKDF2_ITERATIONS, self::PBKDF2_HASH_BYTE_SIZE, true )); } { return false; return self::slowEquals( $pbkdf2, self::pbkdf2( $params[self::HASH_ALGORITHM_INDEX], $password, $params[self::HASH_SALT_INDEX], (int) $params[self::HASH_ITERATION_INDEX], strlen($pbkdf2), true ) ); } // compares two strings $a and $b in length-constant time. { { $diff |= ord($a[$i]) ^ ord($b[$i]); } return $diff === 0; } { if ($count <= 0 || $key_length <= 0) if (function_exists("hash_pbkdf2")) { // The output length is in NIBBLES (4-bits) if $raw_output is false! if (!$raw_output) { $key_length = $key_length * 2; } return hash_pbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output); } $output = ""; for ($i = 1; $i <= $block_count; $i++) { // $i encoded as 4 bytes, big endian. // first iteration $last = $xorsum = hash_hmac($algorithm, $last, $password, true); // perform the other $count - 1 iterations for ($j = 1; $j < $count; $j++) { $xorsum ^= ($last = hash_hmac($algorithm, $last, $password, true)); } $output .= $xorsum; } if ($raw_output) else } }
pomoże ktoś?
proszę niech ktoś mi pomoże.