zoukankan      html  css  js  c++  java
  • C# CRC

      public static string CRC16(string cmdString)
            {
                try
                {
                    //CRC寄存器
                    //int CRCCode = 0;
                  
                    ushort crc = 0xFFFF;
                    for (int i = 0; i < cmdString.Length / 2; i++)
                    {
                        ushort cmdHex =(ushort)Convert.ToInt16( cmdString.Substring(i * 2, 2),16);
                        crc = (ushort)(crc ^ (cmdHex));
                        for (int j = 0; j < 8; j++)
                        {
                            crc = (crc & 1) != 0 ? (ushort)((crc >> 1) ^ 0xA001) : (ushort)(crc >> 1);
                        }
                    }
                    byte hi = (byte)((crc & 0xFF00) >> 8); //高位置
                    byte lo = (byte)(crc & 0x00FF); //低位置
                    string his = Convert.ToString(hi, 16);
                    string los = Convert.ToString(lo, 16);
                    string res = los + his;
                    return res;
                 
                      
                  
                }
                catch
                {
                    throw;
                }
            }
  • 相关阅读:
    tomcat 配置ssi
    oracle exp imp 导入 正在跳过表 plsql 导入表 成功终止 数据 被导入
    oracle 创建数据表空间和用户
    移动端开发来个总结吧
    ssl四次握手
    面试-布局
    typeof的原理?
    马上面试了就,复习一下排序
    关于webview无法设置页面标题
    关于let的生命提升
  • 原文地址:https://www.cnblogs.com/xuchanghua/p/12125694.html
Copyright © 2011-2022 走看看