Skip to content

Instantly share code, notes, and snippets.

@5342

5342/Output Secret

Created January 7, 2013 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 5342/10a3231c1e5f29c5fb10 to your computer and use it in GitHub Desktop.
Save 5342/10a3231c1e5f29c5fb10 to your computer and use it in GitHub Desktop.
The key is: 5ab678a3efaac87a07dc29c8827a245f273a8f5cb4bb1485fd36b42b0fdd4f5e05709e0c8a2ebbe851ab7a
Plain Text: zone-4-9D469367-B60E-4E08-BDF1-FED7CC74AF33
using System;
namespace xorStrings
{
class Program
{
static void Main(string[] args)
{
string cipherText = "20d916c6c29ee53c30ea1effc63b1c72147eb86b998a25c0cf1bf66939e8621b3132d83abb1683df619238";
string plainText = "zone-4-F7677DA8-3D77-11E2-BB65-E4BF6188709B";
string unknownKey = "";
string newCipherText = "20d916c6c29ee54343e81ff1b14c1372650cbf19998f51b5c51bf66f49ec62184034a94fc9198fa9179849";
string unknownPlainText = "";
for (int i = 0; i < cipherText.Length/2; i++)
{
int ct = Convert.ToInt32(cipherText.Substring(i * 2, 2), 16);
int pt = char.Parse(plainText.Substring(i, 1));
unknownKey += (ct ^ pt).ToString("X2");
}
Console.WriteLine("The key is: {0}", unknownKey.ToLower());
for (int i = 0; i < newCipherText.Length / 2; i++)
{
int ct = Convert.ToInt32(newCipherText.Substring(i * 2, 2), 16);
int ky = Convert.ToInt32(unknownKey.Substring(i * 2, 2), 16);
unknownPlainText += (char)(ct ^ ky);
}
Console.WriteLine("Plain Text: {0}", unknownPlainText);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment