/// <summary>
/// 计算16进制字符串几个数据的异或值
/// 例如:
/// 一个数据是4字节:72012601
/// </summary>
/// <param name="hex"></param>
/// <returns></returns>
public string strXor(string hex)
{
int num1 = 0;
int num2 = 0;
num1 = Int32.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
hex = hex.Remove(0, 2);
while (hex.Length > 0)
{
num2 = Int32.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
hex = hex.Remove(0, 2);
num1 = num1 ^ num2;
}
return string.Format("{0:X000}", num1).PadLeft(2,'0');
}
C#计算16进制字符串几个数据的异或值
最新推荐文章于 2023-07-22 10:58:58 发布