有个VB的方法 转换不过来··高手救命
Shared Function PPPfcs16(ByVal fcs As UInt16, ByVal cp() As Byte, ByVal len As Integer)Dim Cs As UInt16
Dim Cs1 As UInt16
Dim Cs2 As UInt16
Cs = fcs
For i As Integer = 0 To len - 1
Cs1 = Cs
Cs2 = Cs
Cs1 >>= 8
Cs2 = (Cs2 Xor cp(i)) And &HFF
Cs = Cs1 Xor fcstab(Cs2)
Next
PPPfcs16 = Cs
End Function
Shared Function PPPGetChecksum(ByVal cp() As Byte, ByVal len As Integer)
PPPGetChecksum = Not PPPfcs16(&HFFFF, cp, len)
End Function
用软件转换了 但是有几个错误···高手来看看呀 ··搞定了我天天膜拜·!!! --------------------编程问答-------------------- 写成dll,到c#导入直接用! --------------------编程问答-------------------- 目前是这样的 但是不稳定!!!!多线程频繁调用的时候出现问题!!! --------------------编程问答--------------------
汗~VB没玩过!下面看的不是太懂--!能说下功能么--! --------------------编程问答--------------------
PPP校验和算法··· --------------------编程问答-------------------- 楼主还少一个
Cs = Cs1 Xor fcstab(Cs2)
中的fcstab函数,
告诉你一个简单的方法,下一个Reflector,然后反编译用VB写的类文件,用C#语言显示就可以了 --------------------编程问答-------------------- --------------------编程问答-------------------- 顶5楼。 --------------------编程问答--------------------
--------------------编程问答--------------------
public static object PPPfcs16(UInt16 fcs, byte[] cp, int len)
{
UInt16 Cs = default(UInt16);
UInt16 Cs1 = default(UInt16);
UInt16 Cs2 = default(UInt16);
Cs = fcs;
for (int i = 0; i <= len - 1; i++) {
Cs1 = Cs;
Cs2 = Cs;
Cs1 >>= 8;
Cs2 = (Cs2 ^ cp[i]) & 0xff;
Cs = Cs1 ^ fcstab(Cs2);
}
return Cs;
}
public static object PPPGetChecksum(byte[] cp, int len)
{
return !PPPfcs16(0xffff, cp, len);
}
这个是错的....!!! --------------------编程问答-------------------- UInt 16 -> ushort
补充:.NET技术 , C#