Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

[C#][SRC]ROT13 Class

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;
    }
}

I hope that it is useful to you.

Update* Vigenere and ROT_X class to come soon. One more bug fix for Vigenere.
μεγαλομανία
why don't you make a ROT-X class? not just a ROT-13 ...
Anyway i like it.
Thanks
you don't have to get the int value of the char... you just do char > 'a' etc it auto converts
(Jan 11, 2011 10:33 AM)Blue Screen of Death Wrote:  why don't you make a ROT-X class? not just a ROT-13 ...
Anyway i like it.
Thanks

I will be updating it to such a class. I was trying to keep it simple for my first implementation.

(Jan 11, 2011 10:35 AM)haphap Wrote:  you don't have to get the int value of the char... you just do char > 'a' etc it auto converts

Thank you for that. This is the kind of info that I am looking for!
μεγαλομανία
Very nice... will try and test it but first I need to learn C# [:(]
(Jan 11, 2011 11:43 AM)BravoTwoZero Wrote:  Very nice... will try and test it but first I need to learn C# [:(]

I would definetly recommend it.

I may translate this to VB, when I finish a ROT - X class.
μεγαλομανία
(Jan 11, 2011 01:23 PM)Ethereal Wrote:  I would definetly recommend it.

I may translate this to VB, when I finish a ROT - X class.
Ok thankyou , looking forward to next three months which I havw the GSCE's coming up then will start learning C sharp... Thank god!!
Ha nice! Glad people are starting to port encryption to .net.
Nice Caeser Cipher! How 'bout a Vigenere cipher next! That one's my favorite for obscuring symmetric keys!
(Jan 14, 2011 08:02 AM)AssChin79 Wrote:  Nice Caeser Cipher! How 'bout a Vigenere cipher next! That one's my favorite for obscuring symmetric keys!

I've been working on one.

It's all working fine, no errors, except when I decrypt, it changes the encrypted 'z' into an 'a'.

Breakpoints time.

μεγαλομανία
Look into this: http://msdn.microsoft.com/en-US/library/...S.80).aspx

Also this is not a proper Caesar cipher. A Caesar cipher with a shift of 1 will translate a 'z' to a 'a'.
(Jan 15, 2011 07:38 AM)Zer0Fact0r Wrote:  Look into this: http://msdn.microsoft.com/en-US/library/...S.80).aspx

Also this is not a proper Caesar cipher. A Caesar cipher with a shift of 1 will translate a 'z' to a 'a'.

This is a Caesar Cipher of 13. Trust me, I know what I am talking about.

This is ROT13, not generic Caesar Cipher.

Also, I have since updated the class with the '||' operator, so I will update it soon.
μεγαλομανία


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by lockheadApr 22, 2021 07:10 AM 0 146 Apr 22, 2021 07:10 AM
Last Post: lockhead
[C#] by SkofosAug 10, 2019 04:01 PM 3 204 Aug 10, 2019 04:01 PM
Last Post: MavenGradle
[C#] by gigajewAug 5, 2017 02:31 PM 10 557 Aug 5, 2017 02:31 PM
Last Post: Ninja