using System;
namespace ConsoleApp3
{
internal class Program
{
static void Main(string[] args)
{
//Console.WriteLine(GetChkSum("6855907856341268110435343337"));
Console.WriteLine(GetChkSum("68 55 90 78 56 34 12 68 11 04 35 34 33 37"));
}
public static string GetChkSum(string str)
{
int bytChk = 0;
str = str.Replace(" ", "");
for (int i = 0; i < str.Length / 2; i++)
{
bytChk += Convert.ToInt16(str.Substring(2 * i, 2), 16);
}
return Convert.ToByte(bytChk % 256).ToString("x");
}
}
}
C# 计算16进制校验和并返回一个字节字符串
最新推荐文章于 2024-06-13 15:01:30 发布