1. 程式人生 > >幀校驗序列碼FCS

幀校驗序列碼FCS

toupper ati for per convert result int length repl

private static string FCS(string s)
{
int xorResult = 0;
string tempfes = "";
for (int i = 0; i < s.Length; i++)
{
xorResult = xorResult ^ Convert.ToInt32(s[i]);
}
tempfes = Convert.ToString(xorResult, 16);
//補0
if (tempfes.Length == 1)
{
tempfes = "0" + tempfes;
}
return tempfes.ToUpper().Replace(" ","");
}

幀校驗序列碼FCS