TwoCream PasswordHashing - 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 TwoCream PasswordHashing.php
- <?php
- mb_internal_encoding("UTF-8");
- $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++) {
- $iteratedBlock = $b = hash_hmac($algorithm, $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(substr($derivedKey, 0, 256)) . "\n";
- echo "\n";
- echo "Base64: " . base64_encode(substr($derivedKey, 0, 256)) . "\n";
- ?>
File Description
- TwoCream PasswordHashing
- PHP Code
- 20 Jun-2018
- 853 Bytes
You can Share it:
Latest PHP Pastes