Util/MyClass/CRC16.cs

(开头部分) 8KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Util.MyClass
{
    /// <summary>
    /// 文件传输CRC验证类
    /// </summary>
    public class CRC16
    {

        public static String getCrc16Code(String crcString)
        {

            // 转换成字节数组  
            byte[] creBytes = HexString2Bytes(crcString);

            // 开始crc16校验码计算  
            CRC16Util crc16 = new CRC16Util();
            crc16.reset();
            crc16.update(creBytes);
            int crc = crc16.getCrcValue();
            // 16进制的CRC码  
            String crcCode = Convert.ToString(crc, 16).ToUpper();
            // 补足到4位  
            if (crcCode.Length < 4)
            {
                // crcCode = StringUtil.lefgPadding(crcCode, '0', 4);  
                crcCode = crcCode.PadLeft(4, '0');
            }
            return crcCode;
        }

        public static String getCrc16Code(byte[] creBytes)
        {


            // 开始crc16校验码计算  
            CRC16Util crc16 = new CRC16Util();
            crc16.reset();
            crc16.update(creBytes);
            int crc = crc16.getCrcValue();
            // 16进制的CRC码  
            String crcCode = Convert.ToString(crc, 16).ToUpper();
            // 补足到4位  
            if (crcCode.Length < 4)
            {
                // crcCode = StringUtil.lefgPadding(crcCode, '0', 4);  
                crcCode = crcCode.PadLeft(4, '0');
            }
            return crcCode;
        }


        public static String RealHexToStr(String str)
        {
            String hText = "0123456789ABCDEF";
            StringBuilder bin = new StringBuilder();
后面还有 209 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。