Login   Register  
PHP Classes
elePHPant
Icontem

File: usage.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  >  usage.php  >  Download  
File: usage.php
Role: Example script
Content type: text/plain
Description: Usage Script
Class: PHP URL Hash Value HMAC
Generate hashes for URLs to prevent tampering
Author: By
Last change:
Date: 2013-10-21 05:43
Size: 1,363 bytes
 

Contents

Class file image Download
<h2>USAGE :: PHP Message Authentication Code</h2>
<?php
require_once("PhpMessageAuthenticationCode.inc.php");
$obj=new PhpMessageAuthenticationCode();

//---------------------------------------------------------------//
//Example 1
//---------------------------------------------------------------//
$data="30";
$hash=$obj->generateHash($data);
$encode_link=0;

$basiclink=$obj->prepareLink("./test.php"$data$hash$encode_link);
echo 
"<hr>MAC Link1: <a target='_blank' href='$basiclink'>$basiclink</a>";


//---------------------------------------------------------------//
//Example 2
//---------------------------------------------------------------//
$data="a=10&b=20&c=30";
$hash=$obj->generateHash($data);
$encode_link=0;

$advancelink1=$obj->prepareLink("./test.php"$data$hash$encode_link);
echo 
"<hr>MAC Link2: <a target='_blank' href='$advancelink1'>$advancelink1</a>";



//---------------------------------------------------------------//
//Example 3
//---------------------------------------------------------------//
$data="param1=value1&amp;param2=value2";
$enc_data=base64_encode($data);
$hash=$obj->generateHash($enc_data);
$encode_link=1;

$advancelink2=$obj->prepareLink("./test.php"$data$hash$encode_link);
echo 
"<hr>MAC Link3: <a target='_blank' href='$advancelink2'>$advancelink2</a>";
?>