| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 | | package com.dy.common.util; |  |   |  | @SuppressWarnings("unused") |  | public class CRC8_for_2_0 { |  |   |  |     @SuppressWarnings("unused") |  |     public int CRC8(byte[] b, int from , int end){ |  |       int crc = 0; |  |       for(int i = from ; i <= end ; i++){ |  |             crc = crc ^ (b[i]); |  |             for(int j = 0; j < 8; j++) { |  |               if((crc & 0x80)!=0) { |  |                  crc ^= 0xe5; |  |               } |  |               crc *= 2; |  |             } |  |       } |  |       return crc; |  |     }  |  |   |  | } | 
 |