– Common Function Library Project

URLEncrypt(cQueryString, nKey)

Last updated February 19, 2003


Timothy Heald

Version: 2 | Requires: CF5 | Library: SecurityLib

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.


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


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 ( 
 * @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


Latest Additions

Kevin Cotton added
May 5, 2016

Raymond Camden added
April 25, 2016

Chris Wigginton added
January 18, 2016

Gary Stanton added
November 19, 2015

Sebastiaan Naafs - van Dijk added
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson