Game Maker Games, Articles, Tutorials & More

Game Maker Network


Howdy, Guest! Please sign in or register an account.

Print

string_ROT13

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;

Comments

There are no comments to display.

Post a Comment

You must be signed in to post comments.

Advertisement