Encryption

key.

A person who needs to read the message must have encrypted text message and key value for which the

impairment is ASCII code. Attention program only encrypts information, program to decrypt try to make yourself. We need to change only one character in Encryption to become Decryption :))

If not there are two attached programs Encryption andDecryption.Try using encryption programs to encrypt the message, then decrypt it using the Decryption program,

as shown in Pictures.

Program code:

/*

* Created by Perić Željko

* periczeljkosmederevo@yahoo.com

* IDE Sharp Develop C#

* Date: 28.11.2011

* Time: 11:20

*

* This is a simple console application for encryption of short

* text messages (up to 255 caracters).It is based on

* increasing of generic ASCII code of letters in text messages

* by value of Rotation_key enterd trough keyboard.

*

* example : Rotation_key = 1

* Message = ABC (ASCII : 65 , 66 , 67)

* Encrypted = BCD (ASCII : 66 ,67 , 68)

*

* Since the value of the ASCII code is limited ,

* so the value of the Rotation_key should be limited

* it is up to you to find min and max values.

* When you do that , given key name will be justified.

*

* !!! The program is not final because it has no part to check

* what exactly user had entered on the keyboard

* there should be try...parse...catch part.

* it is up to you.

* It allso can be modifed to load .txt document,

* encrypt text from it and then send it trough mail,

* for example.

* There is only part of program for encryption,

* the other part for decryption you shuld write

* yourself.Look at this code it should be easy.

* !!!

*

* Good luck and happy learning of C#

*

*/

using System;

namespace Encryption

{

class Program

{

public static void Main(string[] args)

{

//

// variables declaration

//

string Original_Message = "";

string Encrypted_Message = "";

string Original_Message_Letter_String = "";

string Encrypted_Message_Letter_String = "";

string Rotation_key_string = "";

char Original_Message_Letter_Char = ' ';

char Encrypted_Message_Letter_Char = ' ';

int Letter_code = 0;

int Rotation_key_number = 0;

int Message_Lenght = 0;

int Counter = 0;

//

// Hello to user

//

Console.Title = "Encryption program";

Console.SetWindowSize(80,25);

Console.Clear();

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("-------------------------------------------------");

Console.WriteLine(" Program for encryption of text messages");

Console.WriteLine("-------------------------------------------------");

Console.WriteLine("");

//

// Get text message from console

//

Console.WriteLine("Type your message here :");

Console.WriteLine("------------------------");

Original_Message = Console.ReadLine();

Console.WriteLine("");

//

// Get value of rotation key from console

// and transfer it to number

//

Console.WriteLine("Value of rotation key :");

Console.WriteLine("------------------------");

Rotation_key_string = Console.ReadLine();

Rotation_key_number = int.Parse(Rotation_key_string);

Console.WriteLine("------------------------");

Console.WriteLine("");

//

// Encrypt message

//

Message_Lenght = Original_Message.Length;

Counter = 0;

while(Counter < Message_Lenght)

{

Original_Message_Letter_String = Original_Message.Substring(Counter,1);

Original_Message_Letter_Char = char.Parse(Original_Message_Letter_String);

Letter_code = Original_Message_Letter_Char;

Letter_code = Letter_code + Rotation_key_number;

Encrypted_Message_Letter_Char = (char) Letter_code;

Encrypted_Message_Letter_String = Encrypted_Message_Letter_Char.ToString();

Encrypted_Message = Encrypted_Message + Encrypted_Message_Letter_String;

Counter = Counter + 1;

}

//

// Write encrypted message on console

//

Console.WriteLine("Encrypted message");

Console.WriteLine("-------------------------------------------------");

Console.WriteLine(Encrypted_Message);

Console.WriteLine("-------------------------------------------------");

Console.WriteLine("");

//

// End of program

//

Console.Write("Press any key to continue . . . ");

Console.ReadKey(true);

}

}

}

Attached is the complete archive Encryption.rar solution SharpDevelop IDE written in C#, you can download it, and within which is located, in the Release folderthe exe file of the program. Necessary .Net framework 4.0.

Added Decryption.rar with a complete solution SharpDevelop IDE written in C#, you can download and within which is located in the Release folder the exe file of the program. For proper work of program it is necessary to have .Net framework 4.0 ( ^ ) installed.

All the best,

Author

Crypto protection of text messages is an extremely interestingarea in terms of programming. It is the encryption of data in order that accurate information can only be seen by the selectedperson. There are different algorithms and solutions forcryptography, and described below is one of the simplest. It is a "rotation", increase the value of the ASCII code for letters in a message for a particular value that is determined by entering number trough keyboard. Given that each letter was presented on the computer with a unique number of ASCII code(a = 65, b = 66, c = 67, etc.) by increasing the value of ASCIIcode for each letter in a message to say for a one (a = 65 + 1becomes the letter b, b = 66 +1 becomes the letter c, etc.) we get a completely new message that is incomprehensible to all butthe one who has the decryption