For encryption, we consider that the formula is: C = P XOR K, where
* C = encrypted code
* P = plain text
* K = key
For decryption the formula is: P = C XOR K. So, your program will try to find K using this formula. The XOR operator is ^.
using System;
using System.IO;
class Program
{
public static void Main()
{
byte C, K, P;
Console.Write("Enter C: ");
C = byte.Parse(Console.ReadLine());
Console.Write("Enter P: ");
P = byte.Parse(Console.ReadLine());
K = (byte)(C ^ P);
Console.WriteLine("K = " + K);
Console.ReadKey();
}
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C#