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
Jose Diaz-Salcedo added
cfRssFeed
2 day(s) ago
Raymond Compton added
structBlend
23 day(s) ago
Duncan added
IsZIPUK
23 day(s) ago
Todd Sharp added
getTagContentAll
29 day(s) ago
Gerald Guido added
ListReturnDuplicat...
1 month(s) ago