PBKDF2Hashing - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of PBKDF2Hashing.php
- <?php
- mb_internal_encoding("UTF-8");
- $algorithm = 'sha512';
- $password = 'Oyx5UWZ$C\=;Cca!a@T#';
- $salt = 'Cd(G;1V(FZ4BK}~<v;dVNN8j8A}GAwBMiWHgo2l.5uA+)6JR6P!qj?Ux4.YU>nXw';
- $count = 8192;
- $key_length = 256;
- $raw_output = false;
- $hashLength = strlen(hash($algorithm, "", true));
- $keyBlocks = ceil($key_length / $hashLength);
- $derivedKey = '';
- for($block = 1; $block <= $keyBlocks; $block++) {
- // first iteration
- $iteratedBlock = $b = hash_hmac($algorithm, $salt . pack('N', $block), $password, true);
- // perform the other $count - 1 iterations
- $iteratedBlock = $b = hash_hmac('sha512', $salt . pack('N', $block), $password, true);
- for ($i = 1; $i < $count; $i++) {
- $iteratedBlock ^= ($b = hash_hmac($algorithm, $b, $password, true));
- }
- $derivedKey .= $iteratedBlock;
- }
- echo "Hex: " . bin2hex($derivedKey) . "\n";
- echo "\n";
- echo "Base64: " . base64_encode($derivedKey) . "\n";
- ?>
File Description
- PBKDF2Hashing
- PHP Code
- 20 Jun-2018
- 996 Bytes
You can Share it:
Latest PHP Pastes