Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of the XOR function.

Status
Not open for further replies.

KVL

Programmer
May 6, 2002
3
BE
Hello,

I would like to apply the XOR function on two hexadecimal values e.g.
1DABF219597B XOR 75B8F9FFA46D should be 68130BE6FD16.
I think I have to convert the values first to binary ones. Herefore I looked up
some info about the functios FBinFromHex and scanf but it's not clear to me how to use them.
Am I looking at the right direction here? Could somebody help me with these functions and
the XOR function.
Thanks a lot!!!
 
Assuming those are ints or longs and not char* or string values there, you can just do:
cout << 0x1DABF219597B ^ 0x68130BE6FD16;

And get the appropriate value (of course a manipulator would be needed to get that in hex format).
 
these are 64 bit values however. I would look into __int64 and see if that is any help. If not, you can always put this into a char buffer and xor 2 characters at a time with the use of strtol. This will work because 2 characters in hex is 8 bits. XOR does not need to know how big the value is.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top