CFLib.org – Common Function Library Project

URLCheckHash()

Last updated January 07, 2002

author

John Bartlett

Version: 1 | Requires: CF5 | Library: SecurityLib

Description:
After securing a URL by using the URLHash UDF, you can verify that the URL's integrity remains unchanged by verifying the security Hash vale with URLCheckHash.

Return Values:

Example:

Example code will always fail since it checks the CGI variable which will not be correct for this template.

<cfif NOT URLCheckHash()>
  Here you would CFLOCATE, or throw some kind of error.
</cfif>

Parameters:

No arguments.

Full UDF Source:

/**
 * Used along with URLHash to verify the URL integrity.
 * 
 * @author John Bartlett (jbartlett@strangejourney.com) 
 * @version 1, January 7, 2002 
 */
function URLCheckHash()
{
  var tmp=CGI.Query_String;
  var listL=0;
  var loop=0;
  var URLVar="";
  var HashData="";

  if (IsDefined("URL.Hash"))
  {
    if (URL.Hash NEQ "")
    {
      listL=ListLen(tmp,"&");
      URLVar=ListGetAt(tmp,ListL,"&");
      if (Left(UCase(URLVar),5) EQ "HASH=")
      {
        tmp=ListDeleteAt(tmp,ListL,"&");
      }
      HashData=cgi.Server_Name & cgi.Remote_Addr & cgi.Script_Name & tmp;
      if (URL.Hash EQ Hash(HashData)) return 1;
      else return 0;
    } else return 0;
  } else return 0;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson