Guest User

Untitled

a guest
Jun 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. <?php
  2.  
  3. echo "ハッシュアルゴリズムと使用する文字のパターンを変えたときに PHP のセッション ID がどれくらいの長さになるかを検証するマシーン".PHP_EOL;
  4.  
  5. $list = hash_algos();
  6. $example = (string)time();
  7. $bits = array(4, 5, 6);
  8.  
  9. echo "アルゴリズム";
  10. foreach ($bits as $bit)
  11. {
  12. echo "\tsession.hash_bits_per_character=".$bit;
  13. }
  14. echo PHP_EOL;
  15.  
  16. $results = array();
  17.  
  18. foreach ($list as $algo)
  19. {
  20. echo $algo."\t";
  21.  
  22. foreach ($bits as $bit)
  23. {
  24. echo floor(strlen(hash($algo, $example, true)) * (8 / $bit))."\t";
  25. }
  26.  
  27. echo PHP_EOL;
  28. }
Add Comment
Please, Sign In to add comment