Encryption software: The Art of encrypting.

Welcome again! Returning visitors and coders, today I’m going to show you an interesting topic that is, how to prepare an encryption software using C# 4.0 and Windows Forms.

Prerequisites :

1. Microsoft Visual Studio. (Mine is Professional Edition.)

2. A little knowledge in C# and .NET; else go through my topic ‘Class on Classes and Objects’.

First of all, let us understand the need for an encryption software. Just think of you sending a message of extreme confidentiality, someone else fetches it and goes through it. A breach in the security! We can’t allow that to happen. So, virtually every data send over a network is encrypted now-a-days.

Take an example, what i have written so far is normal human readable, meaningful sentences, conveying some meaning. Let’s look at this now:

Vdmbnld!`f`ho !Sdutsohof!whrhunsr!`oe!bnedsr-!une`x!H&l!fnhof!un!rinv!xnt!`o!houdsdruhof!unqhb!ui`u!hr-!inv!un!qsdq`sd!`o!dobsxquhno!rnguv`sd!trhof!B”!5/1!`oe!Vhoenvr!Gnslr/ Qsdsdpthrhudr!; 0/!Lhbsnrngu!Whrt`m!Rutehn/!)

Lhod!hr!Qsngdrrhno`m!Dehuhno/( 3/!@!mhuumd!jonvmdefd!ho!B”!`oe!/ODU:!dmrd!fn!uisntfi!lx!unqhb!&Bm`rr!no!Bm`rrdr!`oe!Nckdbur&/ Ghsru!ng!`

mm!mdu!tr!toedsru`oe!uid!odde!gns!`o!dobsxquhno!rnguv`sd/!Ktru!uihoj!ng!xnt!rdoehof!`!ldrr`fd!ng!dyusdld!bnoghedouh`mhux-!rnldnod!dmrd!gdubidr!hu!`oe!fndr!uisntfi!hu/!@!csd`bi!ho!uid!rdbtshux !Vd!b`o&u!`mmnv!ui`u!un!i`qqdo/!Rn-!whsut`mmx!dwdsx!e`u`!rdoe!nwds!`!oduvnsj!hr!dobsxqude!onv,`,e`xr/!

This is absolute fuzzy mess! That’s ‘encryption’ according to my software. Now feed this data back in the software you get usual form the plain English language.

screenshot of the software

This is how it works.

For all who want to download my software   click here . Click on setup–>Install–>Run.

For interested coders:

The code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace encoder
{
    public partial class Form1 : Form
    {
        string str1,str2;
        char[] input;//new char[100];
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            str1 = textBox1.Text;
        }

        private void button1_Click(object sender, EventArgs e)
        {

            input = str1.ToCharArray(); /*converts string to character array*/
            if (input.Length < 100)
            {
                progressBar1.Value = (progressBar1.Maximum / 100) * input.Length;
            }
            else
            {
                progressBar1.Value = progressBar1.Maximum;
            }
            for (int i = 0; i < input.Length; i++)
            {
                //progressBar1.Value = (progressBar1.Maximum / input.Length-1) * i;
                if (input[i] % 2 == 0)
                {
                    input[i] += Convert.ToChar(1);
                }
                else
                {
                    input[i] -= Convert.ToChar(1);
                }
            }
            str2 = new string(input);
            textBox2.Text = Convert.ToString(str2);

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            textBox3.Visible = true;
            textBox3.Text = "Do you want to decipher the code?";
            button3.Visible = true;
            button4.Visible = true;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            button2.Visible = true;
            textBox1.Text = textBox2.Text;
            textBox2.Text = "";
            button1.Visible = false;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            input = str1.ToCharArray(); /*converts string to character array*/
            if (input.Length < 100)
            {
                progressBar1.Value = (progressBar1.Maximum / 100) * input.Length;
            }
            else {
                progressBar1.Value = progressBar1.Maximum;
            }
            for (int i = 0; i < input.Length; i++)
            {
                //progressBar1.Value = (progressBar1.Maximum / input.Length-1) * i;
                if (input[i] % 2 == 0)
                {
                    input[i] += Convert.ToChar(1);
                }
                else
                {
                    input[i] -= Convert.ToChar(1);
                }
            }
            str2 = new string(input);
            textBox2.Text = Convert.ToString(str2);
            textBox3.Visible = false;
            button3.Visible = false;
            button4.Visible = false;
            textBox1.Text = "";
        }

       /*private void progressBar1_Click(object sender, EventArgs e)
        {

        }*/

    }
}

That's it..Happy coding!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s