Created
February 2, 2012 17:55
-
-
Save raphaelsaunier/1724857 to your computer and use it in GitHub Desktop.
validate_hash.php
This file contains 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 | |
$key = 'our passphrase here'; | |
$hash = 'f8956ba8af19b58e6a92e234abfebf13'; | |
// Encryption function we'll use on our side. This would be retrieved as $_POST['signature'] on your side. | |
$signature = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $hash, MCRYPT_MODE_CBC, md5(md5($key)))); | |
$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($signature), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); | |
if($hash == $decrypted) | |
{ | |
// The hash is valid.. | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment