www.pudn.com > CS_ActiveRFID-DEMO_20140107A.rar > CRC.cs, change:2014-01-07,size:833b


using System; 
using System.Collections.Generic; 
using System.Text; 
 
/* 
 *  
 * This project is for active RFID demo test; 
 * Created by Bill.Zhang 
 * Copyright reserved 2014; 
 *  
 */ 
 
 
namespace CS_ActiveRFID_DEMO 
{ 
    public class CRC 
    { 
        static public byte CRC7(byte[] chr, int cnt) 
        { 
            int i, a; 
            byte crc, Data; 
            crc = 0; 
            for (a = 0; a < cnt; a++) 
            { 
                Data = chr[a]; 
                for (i = 0; i < 8; i++) 
                { 
                    crc <<= 1; 
                    if (((Data & 0x80) ^ (crc & 0x80)) > 0) 
                        crc ^= 0x09; 
                    Data <<= 1; 
                } 
            } 
            crc = (byte)((crc << 1) | 1); 
            return (crc); 
        } 
    } 
}