Skip to content

Instantly share code, notes, and snippets.

@amin007
Created December 8, 2015 08:47
Show Gist options
  • Save amin007/d47cc294b3fddbc58fa9 to your computer and use it in GitHub Desktop.
Save amin007/d47cc294b3fddbc58fa9 to your computer and use it in GitHub Desktop.
buat passsword guna md5
<?php
class Hash
{
/**
*
* @param string $algo The algorithm (md5, sha1, whirlpool, etc)
* @param string $data The data to encode
* @param string $salt The salt (This should be the same throughout the system probably)
* @return string The hashed/salted data
*/
public static function create($algo, $data, $salt)
{
$context = hash_init($algo, HASH_HMAC, $salt);
hash_update($context, $data);
return hash_final($context);
}
public static function rahsia($algo, $data)
{
$context = hash_init($algo);
hash_update($context, $data);
return ($data==null) ? $data : hash_final($context);
}
public static function asal($algo, $data)
{
return $data;
}
}
?>
<form method="POST" action="test3.php">
<label align="center" style="font-size: 20pt; background-color: #000000;
color:#ffffff">Sihat ker <br>Masukkan kata laluan</label>
<input name="password" type="password" size="25" tabindex="1">
<input type="submit" name="masuk" value="Masuk">
</form>
<?php
//echo 'Asal:' . Hash::asal('md5', $_POST['password']) . ': ';
echo ' Kod:' . Hash::rahsia('md5', $_POST['password']) . ': ';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment