用于校驗GPS報文指令的有效性
public static bool Verify(string gpsInfo)
{
if (gpsInfo == null || "".Equals(gpsInfo))
return false;
char p = gpsInfo[0];
char c = (char)0;
int i = 1;
for (; i < gpsInfo.Length; i++)
{
p = gpsInfo[i];
if (p == '*')
break;
c ^= p;
}
if (p != '*')
return false;
return gpsInfo.Substring(++i).Equals(string.Format("{0:X}", (int) c));
}
---------------------------------------------------------
專注移動開發
Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
posted on 2010-05-01 10:26
TiGERTiAN 閱讀(1950)
評論(0) 編輯 收藏 所屬分類:
DotNet