Question: Topic - Cybersecurity Using Windows Forms App C# Create three applications: 1. Only component is a button which generate a random key and save it
Topic - Cybersecurity Using Windows Forms App C#
Create three applications: 1. Only component is a button which generate a random key and save it to cypherkey.txt file.
2. Component is a textbox and a button. This application is to encode text from textbox and save result to encodetext.txt file (use a key from cypherkey.txt for encoding)
3. Component is a textbox and a button. This application is to decode text from encodetext.txt and show result in the textbox
Below are notes how to encode(the first one) and decode(the second one):


byte[] cipherbytes; byte[] Key; byte[] IV; SymmetricAlgorithm sa = DES.Create(); sa.GenerateKey(); Key = sa.Key; sa. GenerateIVO; IV = sa.IV; sa.Mode = CipherMode.ECB; sa.Padding = PaddingMode.PKCS7; MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, sa.CreateEncryptor(), CryptoStreamMode.Write); byte[] plainbytes = Encoding.UTF8.GetBytes("Ilpon 3BOJILHUI TEKCT"); cs.Write(plainbytes, 0, plainbytes.Length); cipherbytes = ms.ToArray(); cs.Close(); ms.Close(); Console.WriteLine(Encoding.UTF8.GetString(cipherbytes)); SymmetricAlgorithm sa = DES.Create(); sa.Key = Key; sa.IV = IV; sa.Mode = Cipher Mode.ECB; sa.Padding = Padding Mode.PKCS7; MemoryStream ms = new MemoryStream(cipherbytes); CryptoStream es = new CryptoStream ms, sa.CreateEncryptor, CryptoStreamMode.Read); byte[] plainbytes = new Byte[cipherbytes.Length); cs.Read(plainbytes, 0, cipherbytes.Length); cs.Close(); ms.Close(); Console.WriteLine(Encoding.UTF8.GetString(plainbytes)); byte[] cipherbytes; byte[] Key; byte[] IV; SymmetricAlgorithm sa = DES.Create(); sa.GenerateKey(); Key = sa.Key; sa. GenerateIVO; IV = sa.IV; sa.Mode = CipherMode.ECB; sa.Padding = PaddingMode.PKCS7; MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, sa.CreateEncryptor(), CryptoStreamMode.Write); byte[] plainbytes = Encoding.UTF8.GetBytes("Ilpon 3BOJILHUI TEKCT"); cs.Write(plainbytes, 0, plainbytes.Length); cipherbytes = ms.ToArray(); cs.Close(); ms.Close(); Console.WriteLine(Encoding.UTF8.GetString(cipherbytes)); SymmetricAlgorithm sa = DES.Create(); sa.Key = Key; sa.IV = IV; sa.Mode = Cipher Mode.ECB; sa.Padding = Padding Mode.PKCS7; MemoryStream ms = new MemoryStream(cipherbytes); CryptoStream es = new CryptoStream ms, sa.CreateEncryptor, CryptoStreamMode.Read); byte[] plainbytes = new Byte[cipherbytes.Length); cs.Read(plainbytes, 0, cipherbytes.Length); cs.Close(); ms.Close(); Console.WriteLine(Encoding.UTF8.GetString(plainbytes))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
