Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caesar Cipher in C#

Tags:

c#

encryption

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?

like image 977
The_Cthulhu_Kid Avatar asked Dec 14 '11 08:12

The_Cthulhu_Kid


People also ask

What is Caesar cipher in C?

It's simply a type of substitution cipher, i.e., each letter of a given text is replaced by a letter with a fixed number of positions down the alphabet. For example with a shift of 1, A would be replaced by B, B would become C, and so on.

What is cipher C?

Ciphertext is encrypted text transformed from plaintext using an encryption algorithm. Ciphertext can't be read until it has been converted into plaintext (decrypted) with a key. The decryption cipher is an algorithm that transforms the ciphertext back into plaintext.

What is Caesar cipher used for?

Caesar Box. The "Caesar Box," or "Caesar Cipher," is one of the earliest known ciphers. Developed around 100 BC, it was used by Julius Caesar to send secret messages to his generals in the field. In the event that one of his messages got intercepted, his opponent could not read them.


1 Answers

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

like image 173
eFloh Avatar answered Sep 30 '22 02:09

eFloh