Search code examples
c#encryption

Caesar Cipher in C#


If I want to write a Caesar cipher C# do I have to go through every case? It doesn't make sense to me to convert to ASCII or UTF (probably because I don't understand how it would work). I just need a point in the right direction.

Should I assign each letter the numbers 1-26?


Solution

  • You could put each letter into an array and use the array index (wrapping at the end) or you could simply use the asccii value of the letter and wrap to the first when reaching the last. The trick here is that all the characters are coninuously sorted, starting at A=0x41