Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › XOR Hex string help in C or C++
New Posts  All Forums:Forum Nav:

XOR Hex string help in C or C++

post #1 of 6
Thread Starter 
I need help to xor two hex strings together. It has been a long time since I touched programming so I have issue here. Basically I have two hex strings in the length of 166, like this,

29460ba9babebbbefd001547a810e67149caee11d945cd7fc81a05e9f85aac650e9052ba6a8cd8257bf14d13e6f0a803b54fde9e77472dbff89d71b57bddef121336cb85ccb8f3315f4b52e301d16e9f52f904

I need to store these hex strings, xor them together, then print the result back (still in the form of hex string). I don't know how to store something this long in a variable.
Misaka
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-3570K ASRock Z68 Extreme4 Gen3 Sapphire HD 7850 2 GB Samsung DDR3 16 GB (30 nm) 
Hard DriveHard DriveOptical DriveCooling
Crucial M4 128 GB WD Caviar Blue 1 TB Lite-on DVD Burner Thermalright Venomous X 
OSOSMonitorKeyboard
Windows 7 Professional x64 (Host) Crunchbang Linux x64 (Guest) HP 2311x HP PS/2 Keyboard 
PowerCaseMouseAudio
Rosewill Capstone 450 W Rosewill Challenger Logitech M570 ASUS Xonar D1 
Other
Hauppauge HVR-1250 
  hide details  
Reply
Misaka
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-3570K ASRock Z68 Extreme4 Gen3 Sapphire HD 7850 2 GB Samsung DDR3 16 GB (30 nm) 
Hard DriveHard DriveOptical DriveCooling
Crucial M4 128 GB WD Caviar Blue 1 TB Lite-on DVD Burner Thermalright Venomous X 
OSOSMonitorKeyboard
Windows 7 Professional x64 (Host) Crunchbang Linux x64 (Guest) HP 2311x HP PS/2 Keyboard 
PowerCaseMouseAudio
Rosewill Capstone 450 W Rosewill Challenger Logitech M570 ASUS Xonar D1 
Other
Hauppauge HVR-1250 
  hide details  
Reply
post #2 of 6
Quote:
Originally Posted by trumpet-205 View Post

I need help to xor two hex strings together. It has been a long time since I touched programming so I have issue here. Basically I have two hex strings in the length of 166, like this,

29460ba9babebbbefd001547a810e67149caee11d945cd7fc81a05e9f85aac650e9052ba6a8cd8257bf14d13e6f0a803b54fde9e77472dbff89d71b57bddef121336cb85ccb8f3315f4b52e301d16e9f52f904

I need to store these hex strings, xor them together, then print the result back. I don't know how to store something this long in a variable.
Not sure if this would work (I know ZERO of C++) but couldn't you dump it to a temporary .dat file?
post #3 of 6
Thread Starter 
This is actually for an assignment on cryptography. I was given 12 cipher texts and asked to decrypt one. To do that I first need to xor them together.
Misaka
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-3570K ASRock Z68 Extreme4 Gen3 Sapphire HD 7850 2 GB Samsung DDR3 16 GB (30 nm) 
Hard DriveHard DriveOptical DriveCooling
Crucial M4 128 GB WD Caviar Blue 1 TB Lite-on DVD Burner Thermalright Venomous X 
OSOSMonitorKeyboard
Windows 7 Professional x64 (Host) Crunchbang Linux x64 (Guest) HP 2311x HP PS/2 Keyboard 
PowerCaseMouseAudio
Rosewill Capstone 450 W Rosewill Challenger Logitech M570 ASUS Xonar D1 
Other
Hauppauge HVR-1250 
  hide details  
Reply
Misaka
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-3570K ASRock Z68 Extreme4 Gen3 Sapphire HD 7850 2 GB Samsung DDR3 16 GB (30 nm) 
Hard DriveHard DriveOptical DriveCooling
Crucial M4 128 GB WD Caviar Blue 1 TB Lite-on DVD Burner Thermalright Venomous X 
OSOSMonitorKeyboard
Windows 7 Professional x64 (Host) Crunchbang Linux x64 (Guest) HP 2311x HP PS/2 Keyboard 
PowerCaseMouseAudio
Rosewill Capstone 450 W Rosewill Challenger Logitech M570 ASUS Xonar D1 
Other
Hauppauge HVR-1250 
  hide details  
Reply
post #4 of 6
I would do it by converting each hex character in the string to its numerical equivalent. Then XOR the numbers, and then convert the result back to hex.
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
post #5 of 6
Thread Starter 
Quote:
Originally Posted by tompsonn View Post

I would do it by converting each hex character in the string to its numerical equivalent. Then XOR the numbers, and then convert the result back to hex.

You mean hex to binary? Wouldn't that make it even longer? How would I go about storing them in the variable?

Someone wrote a Java program on exactly what I am looking for, but the program is limited to 256-bit at a time.
http://www.unsw.adfa.edu.au/~lpb/src/XORcalc/index.html
Edited by trumpet-205 - 6/30/12 at 10:05pm
Misaka
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-3570K ASRock Z68 Extreme4 Gen3 Sapphire HD 7850 2 GB Samsung DDR3 16 GB (30 nm) 
Hard DriveHard DriveOptical DriveCooling
Crucial M4 128 GB WD Caviar Blue 1 TB Lite-on DVD Burner Thermalright Venomous X 
OSOSMonitorKeyboard
Windows 7 Professional x64 (Host) Crunchbang Linux x64 (Guest) HP 2311x HP PS/2 Keyboard 
PowerCaseMouseAudio
Rosewill Capstone 450 W Rosewill Challenger Logitech M570 ASUS Xonar D1 
Other
Hauppauge HVR-1250 
  hide details  
Reply
Misaka
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-3570K ASRock Z68 Extreme4 Gen3 Sapphire HD 7850 2 GB Samsung DDR3 16 GB (30 nm) 
Hard DriveHard DriveOptical DriveCooling
Crucial M4 128 GB WD Caviar Blue 1 TB Lite-on DVD Burner Thermalright Venomous X 
OSOSMonitorKeyboard
Windows 7 Professional x64 (Host) Crunchbang Linux x64 (Guest) HP 2311x HP PS/2 Keyboard 
PowerCaseMouseAudio
Rosewill Capstone 450 W Rosewill Challenger Logitech M570 ASUS Xonar D1 
Other
Hauppauge HVR-1250 
  hide details  
Reply
post #6 of 6
Quote:
Originally Posted by trumpet-205 View Post

You mean hex to binary? Wouldn't that make it even longer? How would I go about storing them in the variable?
Someone wrote a Java program on exactly what I am looking for, but the program is limited to 256-bit at a time.
http://www.unsw.adfa.edu.au/~lpb/src/XORcalc/index.html

No I don't mean hex to binary. You have two hex strings. Convert each unicode character in hex to its decimal equivalent, XOR the results and then convert the result back to a hex string. Because both strings are the same length, this should be fairly easy.
You don't need to store anything apart from the two hex strings and the result of XORing - which you will accomplish using a character array.
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › XOR Hex string help in C or C++