Login   Register  
PHP Classes
elePHPant
Icontem

File: test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Er. Rochak Chauhan  >  PHP URL Hash Value HMAC  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Test File
Class: PHP URL Hash Value HMAC
Generate hashes for URLs to prevent tampering
Author: By
Last change:
Date: 2013-10-21 05:43
Size: 688 bytes
 

Contents

Class file image Download
<h2>TEST :: PHP Message Authentication Code</h2>
<?php
if(isset($_GET['hash']) &&  isset($_GET['data']) ){
    
$data_encoded=0;
    
    
extract($_GET);
    require_once(
"PhpMessageAuthenticationCode.inc.php");
    
$obj=new PhpMessageAuthenticationCode();
    if(isset(
$encoded) && $encoded==1){
        
$data_encoded=1;
    }    
    
    
$data=$obj->compareHash($hash$data,$data_encoded);
    if(
$data !=FALSE){
        echo 
"Valid Link: Data = $data";
    }
    else{
        throw new 
Exception('FATAL ERROR: Mismached Hash and Data. Please try again. <a href="usage.php">Usage</a>');
    }
}
else{
        throw new 
Exception('FATAL ERROR: Invalid or NO Hash and Data. Please try again. <a href="usage.php">Usage</a>');
}
?>