<?php
require_once 'Crypt/HMAC.php';
$hash = new Crypt_HMAC('SECRETKEY', 'sha1');
if (isset($_COOKIE['stamp'])) {
if ($_COOKIE['stamp'] == $hash->hash($_COOKIE['data'])) {
echo "Validated!\n";
} else {
echo "<blink>Not validated</blink>";
}
} else {
$_COOKIE['data'] = '00110100011';
$_COOKIE['stamp'] = $hash->hash($_COOKIE['data']);
}
?>
- pear install Crypt_HMAC
- RFC 2104 implementation
- MD5 and SHA1 supported