-
Notifications
You must be signed in to change notification settings - Fork 1
/
hashtest.php
39 lines (34 loc) · 879 Bytes
/
hashtest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>hash-test PHP vs. JS</title>
<script type="text/javascript" src="sha256hash.js"></script>
</head>
<body>
<?php
$HASH_ROUNDS= 350;
function boldSHA256($h, $c) {
for($i=0;$i<$c;$i++) $h= hash("sha256", $h, false);
return $h;
}
$hash= isset($_POST['hash']) ? $_POST['hash'] : "";
if ($hash!="") {
echo "PHP: ".boldSHA256($hash, $GLOBALS["HASH_ROUNDS"]);
?>
<br/>
<script type="text/javascript">
document.write("JS: "+boldSHA256("<?=$hash?>", <?=$HASH_ROUNDS?>));
</script>
<?php
}
?>
<br/><br/>
<form name="theform" action="hashtest.php" method="POST">
entry to hash: <br/>
<input type="text" size="15" name="hash" id="hash">
<br/><br/>
<input type="submit" name="submit" value="hash it!">
</form>
</body>
</html>