Question

In: Computer Science

A, B:    Design and Implement a C# windows form application to encrypt and decrypt text....

A, B:    Design and Implement a C# windows form application to encrypt and decrypt text. The application use to receive a string and display another encrypted string. The application also decrypt the encrypted string.
The approach for encryption/decryption is simple one i.e. to encrypt we will add 1 to each character, so that "hello" would become "ifmmp", and to decrypt we would subtract 1 from each character.   
C:   Test and evaluate application by applying different strings.   
   Design user friendly Graphical User Interface (GUI) to serve the purpose.
   You can adopt more powerful approach and algorithm for text Encryption/Decryption.

Solutions

Expert Solution

Here is the answer for your question in C# Programming Language.

Kindly upvote if you find the answer helpful.

####################################################################

CODE :

form1.cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace EncryptDecrypt

{

       public partial class Form1 : Form

       {

              public Form1()

              {

                     InitializeComponent();

              }

              private void encryptText(object sender, EventArgs e)

              {

                     //Gets original text from text box for encryption

                     string originalTxt = originalText1.Text;

                     string encryptedTxt = "";

                     //If it has more than one character

                     if(originalTxt.Length > 0)

                     {

                           //Moves each character to next character and adds toa new string

                           foreach(char eachChar in originalTxt)

                           {

                                  encryptedTxt += (char)((int)eachChar + 1);

                           }

                           //Sets new string to encrypted text box

                           encryptedText1.Text = encryptedTxt;

                     }

              }

              private void clearEncryption(object sender, EventArgs e)

              {

                     //Clears encryption text boxes

                     originalText1.Text = "";

                     encryptedText1.Text = "";

              }

              private void decryptText(object sender, EventArgs e)

              {

                     //Gets encrypted text from text box for decryption

                     string encryptedTxt = encryptedText2.Text;

                     string originalTxt = "";

                     //If the encrypted string has atleast one character

                     if (encryptedTxt.Length > 0)

                     {

                           //Moves each character to one letter back and adds to new string

                           foreach (char eachChar in encryptedTxt)

                           {

                                  originalTxt += (char)((int)eachChar - 1);

                           }

                           //Sets original text box with original text

                           originalText2.Text = originalTxt;

                     }

              }

              private void clearDecryption(object sender, EventArgs e)

              {

                     //Clears decryption text boxes

                     encryptedText2.Text = "";

                     originalText2.Text = "";                

              }

       }

}

#####################################################################

Form1.Designer.cs

namespace EncryptDecrypt

{

                partial class Form1

                {

                                /// <summary>

                                /// Required designer variable.

                                /// </summary>

                                private System.ComponentModel.IContainer components = null;

                                /// <summary>

                                /// Clean up any resources being used.

                                /// </summary>

                                /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>

                                protected override void Dispose(bool disposing)

                                {

                                                if (disposing && (components != null))

                                                {

                                                                components.Dispose();

                                                }

                                                base.Dispose(disposing);

                                }

                                #region Windows Form Designer generated code

                                /// <summary>

                                /// Required method for Designer support - do not modify

                                /// the contents of this method with the code editor.

                                /// </summary>

                                private void InitializeComponent()

                                {

                                                this.label1 = new System.Windows.Forms.Label();

                                                this.label2 = new System.Windows.Forms.Label();

                                                this.label3 = new System.Windows.Forms.Label();

                                                this.originalText1 = new System.Windows.Forms.TextBox();

                                                this.label4 = new System.Windows.Forms.Label();

                                                this.label5 = new System.Windows.Forms.Label();

                                                this.encryptedText1 = new System.Windows.Forms.TextBox();

                                                this.encryptBtn = new System.Windows.Forms.Button();

                                                this.clearBtn1 = new System.Windows.Forms.Button();

                                                this.label6 = new System.Windows.Forms.Label();

                                                this.label7 = new System.Windows.Forms.Label();

                                                this.encryptedText2 = new System.Windows.Forms.TextBox();

                                                this.originalText2 = new System.Windows.Forms.TextBox();

                                                this.decryptBtn = new System.Windows.Forms.Button();

                                                this.clearBtn2 = new System.Windows.Forms.Button();

                                                this.SuspendLayout();

                                                //

                                                // label1

                                                //

                                                this.label1.AutoSize = true;

                                                this.label1.Font = new System.Drawing.Font("Times New Roman", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                                                this.label1.ForeColor = System.Drawing.Color.Blue;

                                                this.label1.Location = new System.Drawing.Point(109, 9);

                                                this.label1.Name = "label1";

                                                this.label1.Size = new System.Drawing.Size(375, 26);

                                                this.label1.TabIndex = 0;

                                                this.label1.Text = "ENCRYPION AND DECRYPTION";

                                                //

                                                // label2

                                                //

                                                this.label2.AutoSize = true;

                                                this.label2.BackColor = System.Drawing.Color.Lime;

                                                this.label2.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                                                this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));

                                                this.label2.Location = new System.Drawing.Point(12, 55);

                                                this.label2.Name = "label2";

                                                this.label2.Size = new System.Drawing.Size(141, 22);

                                                this.label2.TabIndex = 1;

                                                this.label2.Text = "Encryption Part";

                                                //

                                                // label3

                                                //

                                                this.label3.AutoSize = true;

                                                this.label3.BackColor = System.Drawing.Color.Yellow;

                                                this.label3.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                                                this.label3.ForeColor = System.Drawing.SystemColors.ControlText;

                                                this.label3.Location = new System.Drawing.Point(12, 203);

                                                this.label3.Name = "label3";

                                                this.label3.Size = new System.Drawing.Size(141, 22);

                                                this.label3.TabIndex = 2;

                                                this.label3.Text = "Decryption Part";

                                                //

                                                // originalText1

                                                //

                                                this.originalText1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                                                this.originalText1.Location = new System.Drawing.Point(129, 104);

                                                this.originalText1.Name = "originalText1";

                                                this.originalText1.Size = new System.Drawing.Size(141, 26);

                                                this.originalText1.TabIndex = 3;

                                                //

                                                // label4

                                                //

                                                this.label4.AutoSize = true;

                                                this.label4.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                                                this.label4.ForeColor = System.Drawing.SystemColors.ControlText;

                                                this.label4.Location = new System.Drawing.Point(12, 104);

                                                this.label4.Name = "label4";

                                                this.label4.Size = new System.Drawing.Size(97, 19);

                                                this.label4.TabIndex = 4;

                                                this.label4.Text = "Original Text";

                                                //

                                                // label5

                                                //

                                                this.label5.AutoSize = true;

                                                this.label5.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                                                this.label5.ForeColor = System.Drawing.SystemColors.ControlText;

                                                this.label5.Location = new System.Drawing.Point(12, 148);

                                                this.label5.Name = "label5";

                                                this.label5.Size = new System.Drawing.Size(111, 19);

                                                this.label5.TabIndex = 5;

                                                this.label5.Text = "Encrypted Text";

                                                //

                                                // encryptedText1

                                                //

                                                this.encryptedText1.Enabled = false;

                                                this.encryptedText1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                                                this.encryptedText1.Location = new System.Drawing.Point(129, 149);

                                                this.encryptedText1.Name = "encryptedText1";

                                                this.encryptedText1.Size = new System.Drawing.Size(141, 26);

                                                this.encryptedText1.TabIndex = 6;

                                                //

                                                // encryptBtn

                                                //

                                                this.encryptBtn.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                                                this.encryptBtn.Location = new System.Drawing.Point(300, 91);

                                                this.encryptBtn.Name = "encryptBtn";

                                                this.encryptBtn.Size = new System.Drawing.Size(103, 33);

                                                this.encryptBtn.TabIndex = 7;

                                                this.encryptBtn.Text = "Encrypt";

                                                this.encryptBtn.UseVisualStyleBackColor = true;

                                                this.encryptBtn.Click += new System.EventHandler(this.encryptText);

                                                //

                                                // clearBtn1

                                                //

                                                this.clearBtn1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                                                this.clearBtn1.Location = new System.Drawing.Point(300, 149);

                                                this.clearBtn1.Name = "clearBtn1";

                                                this.clearBtn1.Size = new System.Drawing.Size(103, 33);

                                                this.clearBtn1.TabIndex = 8;

                                                this.clearBtn1.Text = "Clear";

                                                this.clearBtn1.UseVisualStyleBackColor = true;

                                                this.clearBtn1.Click += new System.EventHandler(this.clearEncryption);

                                                //

                                                // label6

                                                //

                                                this.label6.AutoSize = true;

                                                this.label6.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                                                this.label6.ForeColor = System.Drawing.SystemColors.ControlText;

                                                this.label6.Location = new System.Drawing.Point(12, 246);

                                                this.label6.Name = "label6";

                                                this.label6.Size = new System.Drawing.Size(111, 19);

                                                this.label6.TabIndex = 9;

                                                this.label6.Text = "Encrypted Text";

                                                //

                                                // label7

                                                //

                                                this.label7.AutoSize = true;

                                                this.label7.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                                                this.label7.ForeColor = System.Drawing.SystemColors.ControlText;

                                                this.label7.Location = new System.Drawing.Point(12, 286);

                                                this.label7.Name = "label7";

                                                this.label7.Size = new System.Drawing.Size(97, 19);

                                                this.label7.TabIndex = 10;

                                                this.label7.Text = "Original Text";

                                                //

                                                // encryptedText2

                                                //

                                                this.encryptedText2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                              &nbs


Related Solutions

A, B:   Design and Implement a C# windows form application to ask the user for 10...
A, B:   Design and Implement a C# windows form application to ask the user for 10 integer numbers, sort them in ascending order and display the sorted list. Use bubble sort technique to sort the array elements and do not use any built-in sort method to sort the array elements.                                                        [02] C:    Test and evaluate your program by inputting variety of values.
how to write program in java for encrypt and decrypt input text using DH algorithm
how to write program in java for encrypt and decrypt input text using DH algorithm
Part 1: Design a Cipher allow user to use a “key” to encrypt and decrypt the...
Part 1: Design a Cipher allow user to use a “key” to encrypt and decrypt the message. Use at least two ciphers combined to design your own cipher Specify the min. and max. length of the message user can enter to encrypt Specify the length of the “key” user can enter to encrypt and decrypt the message Part 2: Programme the cipher and make it available to validate. Cleartext for the original programming scripts has to submitted. A frontend webpage...
C# Programming Discuss how to build a Multi-Form Windows application in C#. That is an App...
C# Programming Discuss how to build a Multi-Form Windows application in C#. That is an App that has more than one form, like say maybe 5 forms. How do you connect these forms and pass data objects between these forms?
Answer in python! 5.16 LAB: Cryptographic Hashing Algorithms Encrypting text allows us to encrypt and decrypt...
Answer in python! 5.16 LAB: Cryptographic Hashing Algorithms Encrypting text allows us to encrypt and decrypt the text using a special key. Another method of encrypting text / passwords is called hashing. Hashing uses special algorithms to 'scramble' text so that it is tougher to hack. The hash function can take numbers, letters, and symbols then uses one of the special algorithms to output scrambled text. The longer the output string, the harder to hack the data. The difference between...
Create a Windows application in C# that can be used to change the form color. Your...
Create a Windows application in C# that can be used to change the form color. Your form background color should initially be blue. Provide at least two buttons with two different color choices and a Reset option. Change the font style and size on buttons. Align the buttons so that they are in the center of the form. The color choice buttons should be the same size. Add event handlers for the buttons so that when the user click the...
Create a windows form application in C# that looks and functions like a basic calculator. It...
Create a windows form application in C# that looks and functions like a basic calculator. It must do the following: Add, subtract, multiply, and divide. Account for division by zero. Show at least two decimal places. Retain the last number on the window so that, when the user opens the calculator the next time, the number that was in the window at the last close appears. Have a memory, so that users can store values and recall them. Operate with...
Design and implement a Demand Paging virtual memory simulator! It must be a text based application...
Design and implement a Demand Paging virtual memory simulator! It must be a text based application (NOT a GUI based one). You can use the C/C++ or Java programming language. The following algorithms must be implemented: FIFO, OPT, LRU and LFU. The application must simulate the execution of each of these algorithms on a hypothetical computer having only N physical frames (numbered from 0 to N-1, N<8), assuming that the single process that is running has a virtual memory of...
Design and implement a Demand Paging virtual memory simulator! It must be a text based application...
Design and implement a Demand Paging virtual memory simulator! It must be a text based application (NOT a GUI based one). You can use the C/C++ or Java programming language. The following algorithms must be implemented: FIFO, OPT, LRU and LFU. The application must simulate the execution of each of these algorithms on a hypothetical computer having only N physical frames (numbered from 0 to N-1, N<8), assuming that the single process that is running has a virtual memory of...
Design and implement a Demand Paging virtual memory simulator! It must be a text based application...
Design and implement a Demand Paging virtual memory simulator! It must be a text based application (NOT a GUI based one). You can use the C/C++ or Java programming language. The following algorithms must be implemented: FIFO, OPT, LRU and LFU. The application must simulate the execution of each of these algorithms on a hypothetical computer having only N physical frames (numbered from 0 to N-1, N<8), assuming that the single process that is running has a virtual memory of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT