URLEncrypt(cQueryString, nKey)
Last updated February 19, 2003
Version: 2 | Requires: ColdFusion 5 | 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 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:
<cfscript>
/**
* 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;
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
10 day(s) ago
Will Belden added
longTime
15 day(s) ago
James Sleeman added
quickSort
25 day(s) ago
Ben Forta added
GetHostAddress
28 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)