Xref: utzoo comp.sources.wanted:16403 comp.lang.c:38648 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!swrinde!ucsd!mvb.saic.com!dayton.saic.com!ake From: ake@dayton.saic.com (Earle Ake) Newsgroups: comp.sources.wanted,comp.lang.c Subject: Re: CRC-16 source code wanted Message-ID: <1991Apr24.094046.1582@dayton.saic.com> Date: 24 Apr 91 13:40:46 GMT References: <461@frcs.UUCP> Distribution: comp Organization: Science Applications Intl. Corp., Dayton, Ohio Lines: 33 In article <461@frcs.UUCP>, paul@frcs.UUCP (Paul Nash) writes: > > I am looking for C source code to implement the CRC-16 algorithm. I > have seen various from time to time, but cannot think of a place. If > you have a suitable (short) routine, please post it or mail me a copy, > or tell me where I can find one. int calcrc(prt, count) char *ptr; int count; { int crc, i; crc = 0; while (--count >= 0) { crc = crc ^ (int)*ptr++ << 8; for (i = 0; i < 8; ++i) if (crc & 0x8000) crc = crc << 1 ^ 0x1021; else crc = crc << 1; } return (crc & 0xFFFF); } Earle _____________________________________________________________________________ ____ ____ ___ Earle Ake /___ /___/ / / Science Applications International Corporation ____// / / /__ Dayton, Ohio ----------------------------------------------------------------------------- Internet: ake@dayton.saic.com uucp: dayvb!ake SPAN: 28284::ake