Rot13(string)
Last updated August 23, 2001
Version: 1 | Requires: ColdFusion 5 | Library: SecurityLib
Description:
Stands for "rotate alphabet 13 places". Caesar-cypher encryption that replaces each English letter with the one 13 places forward or back along the alphabet. The same function is used to both encrypt and decrypt a string.
Return Values:
Returns a string.
Example:
<CFSET Encrypted = Rot13(String)>
<CFSET Decrypted = Rot13(Encrypted)>
<CFOUTPUT>
<B>Original:</B><BR>
#String#
<P>
<B>Encrypted:</B><BR>
#Encrypted#
<P>
<B>Dencrypted:</B><BR>
#Decrypted#
</CFOUTPUT>
Parameters:
| Name | Description | Required |
|---|---|---|
| string | String you wish to rot13 encrypt. | Yes |
Full UDF Source:
<cfscript>
/**
* Caesar-cypher encryption that replaces each English letter with the one 13 places forward or back along the alphabet.
*
* @param string String you wish to rot13 encrypt.
* @return Returns a string.
* @author Rob Brooks-Bilson (rbils@amkor.com)
* @version 1.0, August 23, 2001
*/
function rot13(string)
{
var i=0;
var j=0;
var k=0;
var out="";
for (i=1; i LTE Len(String); i=i+1){
j=Asc(Mid(string, i, 1));
if(j GTE 65 AND j LTE 90){
j=((J-52) MOD 26)+65;
}
else if(j GTE 97 AND j LTE 122){
j=((j-84) MOD 26)+97;
}
out=out&Chr(j);
}
return out;
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
4 day(s) ago
Will Belden added
longTime
9 day(s) ago
James Sleeman added
quickSort
19 day(s) ago
Ben Forta added
GetHostAddress
22 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)