Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
Bit different to my last set of questions I a 20 Bit Binary Number I am trying to Xor with a hex value.
C#
 bool UseDefault;
// string SecuirtySeed = "000CEBAD";
 int PassKeyDefault = 8420;
 long SerialNumber = 0;
 string BinaryVersionSerialNumber = "";
 int LoopLength = 0;
 string BinVerSNLast20 = "";
 int IntVerSNLast20 = 0;
 int DigitLoop = 0;
 int[] DevInfoSerialNumber;
 Int32 SecuritySeedInt = 0x000CEBAD;
 Int64 Result;


 // MessageBox.Show("Serial Number Entered is "+txtSerialNumber.Text);

 SerialNumber = Convert.ToInt32(txtSerialNumber.Text);
 lblSerialNumber.Text = SerialNumber.ToString();

 BinaryVersionSerialNumber = Convert.ToString(SerialNumber, 2);

 lblSerialNumberCoded.Text = BinaryVersionSerialNumber.ToString();

 LoopLength = BinaryVersionSerialNumber.Length;

 //Need to know SECURITY SEED   0x000CEBAD
 BinVerSNLast20 = BinaryVersionSerialNumber.Substring(10, 20);
 lblTrimmedSerial.Text = BinVerSNLast20.ToString();

 IntVerSNLast20 = Convert.ToInt32(BinVerSNLast20);
 //and it with 5F's

 //        ^  Xor

 Result = (IntVerSNLast20 ^ SecuritySeedInt);
 MessageBox.Show(Result.ToString());

I have succeeded in trimming off the first bits of the binary number with a substring
to generate the number required I need the Xor to work...
(Note I am not trying hack some encryption, just want to make lives eaiser in the testing phase...)
Posted

1 solution

All that stuff could be reduced to
C#
Int32 SerialNumber;
Int32 Result;
SerialNumber = Convert.ToInt32(txtSerialNumber.Text);
Result = (SerialNumber & 0x000FFFFF) ^ 0x000CEBAD;
MessageBox.Show(Result.ToString());
 
Share this answer
 
Comments
glennPattonWork3 15-May-14 11:58am    
Seems to work, I now have to test it with hardware that doesn't yet exist! (in all in parts next to the guys desk) hence giving me the awkward task to do (while he nips off early to get his car from the garage!)
[no name] 15-May-14 12:06pm    
I would suggest you to accept the answer if it is working for you. This motivates people like CPallini to answer again ;)
glennPattonWork3 15-May-14 12:10pm    
Accepted, all I have to do now reverse the process!
[no name] 15-May-14 12:21pm    
But reverse and xor is realy an easy thing...or I don't get maybe the Point (my english is not very good) ;)
CPallini 15-May-14 12:25pm    
What do you mean exactly? You know (X == (X^Y)^Y) is true.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900