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
- $algorithm = 'sha512';
- $password = 'zz5Xl0rCsH4c/WfS"oJS';
- $salt = 'h>/KTW)NsLOk)qk_]RBz&zPob\\?A,T:]k1kcX%ST0WTxRD.dg]?Rno]2)Nlp0~/8';
- $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 $derivedKey;
- //echo $key_length;
- #echo bin2hex(substr($derivedKey, 0, $key_length));
- echo bin2hex($derivedKey);
- #echo hex2bin ( bin2hex($derivedKey) );
- ?>
File Description
- PBKDF2Hashing
- PHP Code
- 19 Jun-2018
- 1006 Bytes
You can Share it:
Latest PHP Pastes