Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Php Hash Generator
$p = empty($_POST['p']) ? null : $_POST['p'];
<head><title>Hash Olustur</title></head>
<style type="text/css">
table {border-collapse: collapse;}
table, td, th {border: solid 1px #ccc;}
th {background: #e1e1e1;border-color: #999;}
td, th {padding: 0.25em;}
td.algo {font-weight: bold;}
tr.on td {background: #f0f0f0;}
<h1>String hashing</h1>
<form method="post" action="<?php echo basename(__FILE__) ?>">
<p><label for="p">Enter a string to hash:</label><br /><input id="p" type="text" name="p" value="<?php echo $p ?>" /></p>
<p><input type="submit" name="submit" value="Hash It" /></p>
<?php /* If there is a posted value use it */ ?>
<?php if ($p): ?>
<hr />
<h2>Table of hash values for <em><?php echo $p ?></em> based on algorithm</h2>
<th>Hashed value of <em><?php echo $p ?></em></th>
<?php /* Loop through each hash algorithm, colorizing every other row */ ?>
<?php $on = false; foreach (hash_algos() as $algo): ?>
<tr<?php if ($on): ?> class="on"<?php endif; ?>>
<td class="algo"><?php echo $algo ?></td>
<td class="hash"><?php echo hash($algo, $p) ?></td>
<?php $on = !$on; endforeach; ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.