110,538
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 生成校验位
/// </summary>
public static byte GetCode(byte[] by)
{
int x = 0;
for (int i = 0; i < by.Length; i++) x += by[i];
return (byte)(x & 0x000000FF);
}
/// <summary>
/// 生成校验位
/// </summary>
public static byte GetCode(byte[] by)
{
int x = 0;
for (int i = 0; i < by.Length; i++)
{
x += Convert.ToInt32(by[i]);
}
byte[] b = BitConverter.GetBytes(x);
return b[0];
}