root / HServer / 00.Server / 00.Program / node_modules / crc / README.md
이력 | 보기 | 이력해설 | 다운로드 (3.46 KB)
1 |
# crc |
---|---|
2 |
|
3 |
[](https://www.gittip.com/alexgorbatchev/) |
4 |
[](https://david-dm.org/alexgorbatchev/node-crc) |
5 |
[](https://david-dm.org/alexgorbatchev/node-crc?type=dev) |
6 |
[](https://travis-ci.org/alexgorbatchev/node-crc) |
7 |
|
8 |
[](https://npmjs.org/package/crc) |
9 |
|
10 |
Module for calculating Cyclic Redundancy Check (CRC) for Node.js and the Browser. |
11 |
|
12 |
# Important: Node >= 6.3.0 < 6.9.2 |
13 |
|
14 |
There's was a bug in Node [#9342](https://github.com/nodejs/node/issues/9342) that affected CRC calculation if `Buffer.split()` is used (see issue discussion for details). This affected all version starting from `6.3.0` up to but not including `6.9.2`. The patch [#9341](https://github.com/nodejs/node/pull/9341) was released in `6.9.2`. If you are upgrading and seeing odd CRC calculation mismatches, this might be the reason. |
15 |
|
16 |
## Features |
17 |
|
18 |
* Full test suite comparing values against reference `pycrc` implementation. |
19 |
* Pure JavaScript implementation, no dependencies. |
20 |
* Provides CRC tables for optimized calculations. |
21 |
* Provides support for the following CRC algorithms: |
22 |
* CRC1 `crc.crc1(…)` |
23 |
* CRC8 `crc.crc8(…)` |
24 |
* CRC8 1-Wire `crc.crc81wire(…)` |
25 |
* CRC16 `crc.crc16(…)` |
26 |
* CRC16 CCITT `crc.crc16ccitt(…)` |
27 |
* CRC16 Modbus `crc.crc16modbus(…)` |
28 |
* CRC16 Kermit `crc.crc16kermit(…)` |
29 |
* CRC16 XModem `crc.crc16xmodem(…)` |
30 |
* CRC24 `crc.crc24(…)` |
31 |
* CRC32 `crc.crc32(…)` |
32 |
|
33 |
## Installation |
34 |
|
35 |
``` |
36 |
npm install crc |
37 |
``` |
38 |
|
39 |
## Usage |
40 |
|
41 |
Calculate a CRC32: |
42 |
|
43 |
```js |
44 |
var crc = require('crc'); |
45 |
|
46 |
crc.crc32('hello').toString(16); |
47 |
// "3610a686" |
48 |
``` |
49 |
|
50 |
Calculate a CRC32 of a file: |
51 |
|
52 |
```js |
53 |
crc.crc32(fs.readFileSync('README.md', 'utf8')).toString(16); |
54 |
// "127ad531" |
55 |
``` |
56 |
|
57 |
Or using a `Buffer`: |
58 |
|
59 |
```js |
60 |
crc.crc32(fs.readFileSync('README.md')).toString(16); |
61 |
// "127ad531" |
62 |
``` |
63 |
|
64 |
Incrementally calculate a CRC32: |
65 |
|
66 |
```js |
67 |
value = crc.crc32('one'); |
68 |
value = crc.crc32('two', value); |
69 |
value = crc.crc32('three', value); |
70 |
value.toString(16); |
71 |
// "9e1c092" |
72 |
``` |
73 |
|
74 |
## Running tests |
75 |
|
76 |
``` |
77 |
npm test |
78 |
``` |
79 |
|
80 |
## Thanks! |
81 |
|
82 |
[pycrc](http://www.tty1.net/pycrc/) library is which the source of all of the CRC tables. |
83 |
|
84 |
# License |
85 |
|
86 |
The MIT License (MIT) |
87 |
|
88 |
Copyright (c) 2014 Alex Gorbatchev |
89 |
|
90 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
91 |
of this software and associated documentation files (the "Software"), to deal |
92 |
in the Software without restriction, including without limitation the rights |
93 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
94 |
copies of the Software, and to permit persons to whom the Software is |
95 |
furnished to do so, subject to the following conditions: |
96 |
|
97 |
The above copyright notice and this permission notice shall be included in |
98 |
all copies or substantial portions of the Software. |
99 |
|
100 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
101 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
102 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
103 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
104 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
105 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
106 |
THE SOFTWARE. |