]> git.zerfleddert.de Git - proxmark3-svn/blob - common/crc16.c
Limit DbpString size to the buffer size, patch by Andreas from proxmark forums
[proxmark3-svn] / common / crc16.c
1 #include "crc16.h"
2
3 unsigned short update_crc16( unsigned short crc, unsigned char c )
4 {
5 unsigned short i, v, tcrc = 0;
6
7 v = (crc ^ c) & 0xff;
8 for (i = 0; i < 8; i++) {
9 tcrc = ( (tcrc ^ v) & 1 ) ? ( tcrc >> 1 ) ^ 0x8408 : tcrc >> 1;
10 v >>= 1;
11 }
12
13 return ((crc >> 8) ^ tcrc)&0xffff;
14 }
Impressum, Datenschutz