Computer Tech
[C#][SRC]ROT13 Class - Printable Version

+- Computer Tech (https://computertech.createmybb3.com)
+-- Forum: Programming (https://computertech.createmybb3.com/forumdisplay.php?fid=6)
+--- Forum: .Net Programming (https://computertech.createmybb3.com/forumdisplay.php?fid=8)
+--- Thread: [C#][SRC]ROT13 Class (/showthread.php?tid=100)



[C#][SRC]ROT13 Class - Ethereal - 01-15-2011

This is my own ROT13 class. It is fast - it did 10,000 characters instantly(1/5 of a second) and I am pretty proud of it.

Some constructive criticism is Ok, but don't flame.

[code]
class ROT13
{
/// <summary>
/// This is an implementation of the ROT13(Rotation of 13, a.k.a Caesar Shift) algorithm, coded by Ethereal of HackForums.net.
/// This will scramble your string into an unreadable form.
/// </summary>
public string AlterText(string input)
{
char[] text = input.ToCharArray();
for (int i = 0; i < input.Length; i++)
{
int value = (int)text[i];
if (value >= 'a' && value <= 'm' || value >= 'A' && value <= 'M')
{
value += 13;
}
else if (value >= 'm' && value <= 'z' || value >= 'M' && value <= 'Z')
{
value -= 13;
}

text[i] = Convert.ToChar(value);
}
string FinVal = new string(text);
return FinVal;
}
}

[/code]

I hope that it is useful to you.

Update* Vigenere and ROT_X class to come soon. One more bug fix for Vigenere.


RE: [C#][SRC]ROT13 Class - Ironside - 01-15-2011

Interesting, this is definitely a good share.
Will probably come useful in the near future.