I have this function that calculates ROT13.
string function rot13(required string inString) output="false" {
var j = 0;
var k = 0;
var out = "";
for (var i = 1; i <= Len(arguments.inString); i++){
j = asc(Mid(arguments.inString, i, 1));
if(j >= asc("A") && j <= asc("Z")) {
j = ((j - 52) % 26) + asc("A");
}
else if(j >= asc("a") && j <= asc("z")) {
j = ((j - 84) % 26) + asc("a");
}
out &= Chr(j);
} // end for
return out;
}
I don't like that it appears to have 3 magic numbers 52, 26, and 84. I think the 26 can be replace with asc("Z") - asc("A") + 1
But I don't know what the 52 and 84 represent. I don't know what I would name them.