1.0.0 • Published 9 months ago

buffer-crc32 v1.0.0

Weekly downloads
12,418,977
License
MIT
Repository
github
Last release
9 months ago

buffer-crc32

NPM Version Build Status

crc32 that works with binary data and fancy character sets, outputs buffer, signed or unsigned data and has tests.

Derived from the sample CRC implementation in the PNG specification: http://www.w3.org/TR/PNG/#D-CRCAppendix

This package requires Node 8+ to work.

install

npm install buffer-crc32

example

const crc32 = require('buffer-crc32');
// works with buffers
const buf = Buffer([0x00, 0x73, 0x75, 0x70, 0x20, 0x62, 0x72, 0x6f, 0x00]);
crc32(buf); // -> <Buffer 94 5a ab 4a>

// has convenience methods for getting signed or unsigned ints
crc32.signed(buf); // -> -1805997238
crc32.unsigned(buf); // -> 2488970058

// will cast to buffer if given a string, so you can
// directly use foreign characters safely
crc32('自動販売機'); // -> <Buffer cb 03 1a c5>

// and works in append mode too
const partialCrc = crc32('hey');
const partialCrc = crc32(' ', partialCrc);
const partialCrc = crc32('sup', partialCrc);
const partialCrc = crc32(' ', partialCrc);
const finalCrc = crc32('bros', partialCrc); // -> <Buffer 47 fa 55 70>

tests

This was tested against the output of zlib's crc32 method. You can run the tests withnpm test (requires tap)

see also

https://github.com/alexgorbatchev/node-crc, crc.buffer.crc32 also supports buffer inputs and return unsigned ints (thanks @tjholowaychuk).

license

MIT/X11

yauzlarchiverarchiver-jsonreact-native-bluetooth2killi8n-react-native-fast-imagemaxwin_est_timemaxwin_realtime_web@darrinholst/dynalitern-send-smssyzoj-divinecad-climaxwin_est_servertuya-weapp-toolsreact-native-template-rfbaseairscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-modulekubii-apideneme323112@ntt_app/react-native-custom-notificationschoolbotreact-native-covid-sdkreact-native-thanh-toast-library@thanhnguyen14797/react-native-thanh-toast-libraryreact-native-printer-brothersrn-pdf-reader-offlineukor-remasterdyx-reacttemp-mail-fucktalent-to-vite-clinodejs-fileshareone-indexunblock-block-save-variables@infinitebrahmanuniverse/nolb-buf@machiavelli/steam-client@tsightler/weriftopea-bootstraap@everything-registry/sub-chunk-1271@mediakular/svelte-data-grid@wacoco/ytdf3-jssvelte-searchable-selectsvelvet-customtest-js-accounttest-js-contractwinx-form-winxwmf-kafka-nodewolai-decompresswd-dockyardweb-elements-iconsweb-component-tester-bundlewabotakbarvue-infinite-loading-propswebapp-parserwebrtc-stunweriftwerift-icewerift-webrtcwow.js-juziwrenchnpm-ui-componentswhatsconcrn-tm-notifyrn-session-multiplier-demornttlockshainasharingcomponent2session-messenger-nodejssciadvfilesrn-adyen-dropinspotify-ds-sespark-protocol-dtitsteam-forksteamsteam-clientsteam-dizardsteam-upsteam-user-fitchersteam-with-proxysteamhourapiseproseperate-reposedanbosokseikho-sorceryselect2-selectalltesting-storybooktest-public-protestnpm_lmnsvavatarsvelte-crypt-textsweetalert2-denazificationsy_node_rpctext-to-img-craiyon-scrappertextio-sorceryvolatile-redis-clustervarnish-agentvideo-multi-uploaderlayui-customdfeuk-frontenddfeuk-frontend-manual
1.0.0

9 months ago

1.0.0-RC5

9 months ago

1.0.0-RC7

9 months ago

1.0.0-RC8

9 months ago

1.0.0-RC1

9 months ago

1.0.0-RC2

9 months ago

1.0.0-RC3

9 months ago

1.0.0-RC4

9 months ago

1.0.0-RC9

9 months ago

0.2.13

8 years ago

0.2.12

8 years ago

0.2.11

8 years ago

0.2.10

8 years ago

0.2.9

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.1

12 years ago

0.2.0

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago