CFLib.org – Common Function Library Project

URLEncrypt(cQueryString, nKey)

Last updated February 19, 2003

author

Timothy Heald

Version: 2 | Requires: CF5 | Library: SecurityLib

Description:
This is actually two functions. The first urlEncrypt("name=value&name=value&name=value",key) you use when you would have a link or an action that you would be setting url variables in. The second urlDecrypt(key) you use on whatever page you are calling, or using as the form action page.

Return Values:
Returns an encrypted query string.

Example:

<CFSET Name = "Ray">
<CFSET Age = 28>
<CFSET Key = "MySecretBlah348123190">
<CFSET QS = "name=#Name#&age=#Age#">
<CFOUTPUT>
Link will be, foo.cfm#URLEncrypt(QS,key)#
</CFOUTPUT>

Parameters:

Name Description Required
cQueryString Query string to encrypt. Yes
nKey Key to use for encryption. Yes

Full UDF Source:

/**
 * Add security by encrypting and decrypting URL variables.
 * 
 * @param cQueryString 	 Query string to encrypt. (Required)
 * @param nKey 	 Key to use for encryption. (Required)
 * @return Returns an encrypted query string. 
 * @author Timothy Heald (theald@schoollink.net) 
 * @version 2, February 19, 2003 
 */
function urlEncrypt(queryString, key){
	// encode the string
	var uue = cfusion_encrypt(queryString, key);
        
	// make a checksum of the endoed string
	var checksum = left(hash(uue & key),2);
        
	// assemble the URL
	queryString = "/" & uue & checksum &"/index.htm";
		
	return queryString;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson