PHP Classes
elePHPant
Icontem

File: paramAuthArray.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Marcelo Costa  >  securityAuthParam  >  paramAuthArray.php  >  Download  
File: paramAuthArray.php
Role: Example script
Content type: text/plain
Description: exemple
Class: securityAuthParam
Encrypt and verify URL parameters
Author: By
Last change:
Date: 5 years ago
Size: 1,074 bytes
 

Contents

Class file image Download
<?php
include_once ("securityAuthParam.php");

// This exemple query string is a encode64 param

define("PRIVATEKEY", "Marcelo Costa");
define("HASHMODE","ripemd160");// opcional default are ripemd160
define("AUTHMODE", "AUTHARRAY");// opcional default are AUTHARRAY

$Objeto = new securityAuthParam();

// Check ecode auth string in request
if(array_key_exists('param', $_REQUEST))
{
echo
"DECODE REQUEST<br>\r\n";

try {
$CHECK=$Objeto->decodeAuthParam($_REQUEST['param']);
if(
$CHECK==true)
{
echo
"query string ok<br/>\r\n";
var_export($CHECK);
echo
"\r\n<br/><br/>";
}
} catch (
Exception $e) {
echo
"invalid param auth";
}


}


echo
"New array for encode encode<br/><br/>\r\n";

$rand = rand();
$queryArray = array (
   
"id" => 321,
   
"date" => date('d/m/y'),
   
"randon" => $rand
);

var_export($queryArray);
$param=$Objeto->encodeAuthParam($queryArray);

$paramlegth="param=".$param;

echo
"<br/><br/>Encode => ".$param."<br/>\r\n";

echo
"<br/>param length =" . strlen($paramlegth) . " chars,<a href=\"?param=".$param ."\">clique here for decode</a><br/><br/>\r\n";
?>