Answer to Question #21136 in C# for Abdallah

Question #21136
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 ^.
1
Expert's answer
2012-12-25T11:57:25-0500
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS