Created
November 9, 2010 07:24
-
-
Save co3k/668814 to your computer and use it in GitHub Desktop.
ハッシュアルゴリズムと使用する文字のパターンを変えたときに PHP のセッション ID がどれくらいの長さになるかを検証するマシーン
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo "ハッシュアルゴリズムと使用する文字のパターンを変えたときに PHP のセッション ID がどれくらいの長さになるかを検証するマシーン".PHP_EOL; | |
$list = hash_algos(); | |
$example = (string)time(); | |
$bits = array(4, 5, 6); | |
echo "アルゴリズム"; | |
foreach ($bits as $bit) | |
{ | |
echo "\tsession.hash_bits_per_character=".$bit; | |
} | |
echo PHP_EOL; | |
$results = array(); | |
foreach ($list as $algo) | |
{ | |
echo $algo."\t"; | |
foreach ($bits as $bit) | |
{ | |
echo ceil(strlen(hash($algo, $example, true)) * (8 / $bit))."\t"; | |
} | |
echo PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment