I have to do a XOR to calculate an decryption key.
My expected key is "0123456789ABCDEFFEDCBA9876543210" and my sample inputs are
("8D10DA193E98524379264ADFFD043632" and "C339F7EB7339FAC87FAF0478B500422") . Second sample is ( "00000000000000000000000000000000" and "0123456789ABCDEFFEDCBA9876543210")
So here is the thing when I XOR my first sample Iam getting this as a result " 7123456789ABCDEFFEDCBA9876543210" and for my second sample I am getting "123456789ABCDEFFEDCBA9876543210" the leading zero is getting cut off.
I have tried various things but here is the code I settled on:
static void Main(string[] args)
{
const string bdk1 = "8D10DA193E98524379264ADFFD043632";
const string bdk2 = "C339F7EB7339FAC87FAF0478B500422";
//const string bdk1 = "00000000000000000000000000000000";
//const string bdk2 = "0123456789ABCDEFFEDCBA9876543210";
const string expected = "0123456789ABCDEFFEDCBA9876543210";
BigInteger b1 = BigInteger.Parse(bdk1, NumberStyles.HexNumber);
BigInteger b2 = BigInteger.Parse(bdk2, NumberStyles.HexNumber);
BigInteger actual = b1 ^ b2;
string stringRet = actual.ToString("X");//.PadLeft(expected.Length, '0');
Console.WriteLine("Expected: " + expected);
Console.WriteLine("Actual : " + stringRet);
Console.ReadLine();
}
}