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.



Your result can be seen below.

Result of php executing





Full code of TwoCream PasswordHashing.php

  1. <?php
  2.     mb_internal_encoding("UTF-8");
  3.     
  4.     $algorithm = 'sha512';
  5.         $password = 'zz5Xl0rCsH4c/WfS"oJS';
  6.         $salt = 'h>/KTW)NsLOk)qk_]RBz&zPob\\?A,T:]k1kcX%ST0WTxRD.dg]?Rno]2)Nlp0~/8';
  7.         $count = 8192;
  8.         $key_length = 256;
  9.         $raw_output = false;
  10.        
  11.     $hashLength = strlen(hash($algorithm, "", true));
  12.     $keyBlocks = ceil($key_length / $hashLength);
  13.  
  14.         $derivedKey = '';
  15.        
  16.     for($block = 1; $block <= $keyBlocks; $block++) {
  17.  
  18.                 $iteratedBlock = $b = hash_hmac($algorithm, $salt . pack('N', $block),  $password, true);
  19.                
  20.         for ($i = 1; $i < $count; $i++) {
  21.             $iteratedBlock ^= ($b = hash_hmac($algorithm, $b, $password, true));
  22.         }
  23.         $derivedKey .= $iteratedBlock;
  24.     }
  25.        
  26.         echo "Hex: " . bin2hex(substr($derivedKey, 0, 256)) . "\n";
  27.         echo "\n";
  28.     echo "Base64: " . base64_encode(substr($derivedKey, 0, 256)) . "\n";
  29.  
  30. ?>
File Description
  • TwoCream PasswordHashing
  • PHP Code
  • 20 Jun-2018
  • 853 Bytes
You can Share it: