By Daniel · December 30, 2008
"Encrypts" a string using the classic rot13 algorithm. (See ROT13 on Wikipedia.)
// string_ROT13(str)
// "Encrypts" a string using the classic rot13 algorithm
// See http://en.wikipedia.org/wiki/Rot13
var in, out, len, result, i, c, p;
in = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
out = 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm';
len = string_length(argument0);
result = '';
for (i = 1; i <= len; i += 1) {
c = string_char_at(argument0, i);
p = string_pos(c, in);
if (p)
result += string_char_at(out, p);
else
result += c;
}
return result;
Categories: Encryption, String handling
There are no comments to display.
You must be signed in to post comments.