我有两个十六进制字符串:
string x = "928fe46f228555621c7f42f3664530f9";
string y = "56cd8c4852cf24b1182300df2448743a";
我想将它们转换为二进制找到多少位的两位十六进制字符串之间匹配。
我用这个功能来HEX转换为二进制:
string GetBinaryStringFromHexString (string sHex)
{
string sReturn = "";
for (int i = 0; i < sHex.length (); ++i)
{
switch (sHex [i])
{
case '0': sReturn.append ("0000"); break;
case '1': sReturn.append ("0001"); break;
case '2': sReturn.append ("0010"); break;
case '3': sReturn.append ("0011"); break;
case '4': sReturn.append ("0100"); break;
case '5': sReturn.append ("0101"); break;
case '6': sReturn.append ("0110"); break;
case '7': sReturn.append ("0111"); break;
case '8': sReturn.append ("1000"); break;
case '9': sReturn.append ("1001"); break;
case 'a': sReturn.append ("1010"); break;
case 'b': sReturn.append ("1011"); break;
case 'c': sReturn.append ("1100"); break;
case 'd': sReturn.append ("1101"); break;
case 'e': sReturn.append ("1110"); break;
case 'f': sReturn.append ("1111"); break;
}
}
return sReturn;
}
因此,在二进制序列X - > 10010010100011111110010001101111001000101000010101010101011000100001110001111111010000101111001101100110010001010011000011111001
和字符串二进制y为 - > 01010110110011011000110001001000010100101100111100100100101100010001100000100011000000001101111100100100010010000111010000111010
但现在我卡住了,我怎么能异或两个字符串来查找匹配的位数? 我怎么能算呢?
不要紧,我是否使用Java或C ++,谁能帮助请
谢谢,