<?php
if(!isset($_GET['hashtype']))
$_GET['hashtype'] = "";
//Xml
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml" />
<title>PHP Hash</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>
<body class="center">
<h1>PHP Hash</h1>
<form method="get" action="old_hash.php">
<div class="hash">
Hash type :
<select name="hashtype">
<?php
foreach(hash_algos() as $Val)
{
echo "<option value=\"".$Val."\"";
if($_GET['hashtype'] == $Val)
echo " selected=\"selected\"";
echo ">".$Val."</option>\n";
}
?>
</select>
</div>
<div class="hash">
Hash String : <input type="text" name="str" <?php if(isset($_GET['str'])) echo "value=\"".$_GET['str']."\""; ?>/>
</div>
<div class="hash_s">
<input type="submit" value="Valider"/>
</div>
</form>
<?php
if(isset($_GET['hashtype']) && array_search($_GET['hashtype'], hash_algos()) !== false)
{
?>
<table class="hash_res">
<tr>
<th>Original string</th><th>Hashed string</th><th>String lenght</th>
</tr>
<?php
$str_t[] = "azerty";
$str_t[] = "gnu";
$str_t[] = time();
if(isset($_GET['str']) && $_GET['str'] != "")
{
if(is_array($_GET['str']))
$str_t = array_merge($_GET['str'], $str_t);
else
$str_t[] = $_GET['str'];
}
$class = false;
foreach($str_t as $str)
{
$class = !$class;
?>
<tr class="<?php echo ($class)?"line1":"line2"; ?>">
<td><?php echo $str; ?></td>
<td><?php echo $hashed = hash($_GET['hashtype'], $str); ?></td>
<td><?php echo strlen($hashed); ?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
<hr />
<p>
<a href="http://validator.w3.org/check?uri=referer">
<img src="http://www.w3.org/Icons/valid-xhtml11-blue"
alt="Valid XHTML 1.1" height="31" width="88" />
</a>
</p>
</body>
</html>