0.2.2 • Published 6 years ago

xxhashjs v0.2.2

Weekly downloads
890,726
License
MIT
Repository
github
Last release
6 years ago

Javascript implementation of xxHash

Synopsis

xxHash is a very fast hashing algorithm (see the details here). xxhashjs is a Javascript implementation of it, written in 100% Javascript. Although not as fast as the C version, it does perform pretty well given the current Javascript limitations in handling unsigned 32 bits integers.

Installation

In nodejs:

npm install xxhashjs

In the browser, include the following, and access the constructor with XXH:

<script src="/your/path/to/xxhash.js"></script>

Examples

  • In one step:
var h = XXH.h32( 'abcd', 0xABCD ).toString(16)	// seed = 0xABCD

0xCDA8FAE4

  • In several steps (useful in conjunction of NodeJS streams):
var H = XXH.h32( 0xABCD )	// seed = 0xABCD
var h = H.update( 'abcd' ).digest().toString(16)

0xCDA8FAE4

  • More examples in the examples directory: Compute xxHash from a file data Use xxHashjs in the browser

Usage

  • XXH makes 2 functions available for 32 bits XXH and 64 bits XXH respectively, with the same signature:

    	* XXH.h32
    	* XXH.h64
  • In one step: XXH.h32(<data>, <seed>) The data can either be a string, an ArrayBuffer or a NodeJS Buffer object. The seed can either be a number or a UINT32 object.

  • In several steps: * instantiate a new XXH object H: XXH.h32(<seed>) or XXH.h32() The seed can be set later on with the init method

    * add data to the hash calculation:

    H.update(<data>)

    * finish the calculations:

    H.digest()

The object returned can be converted to a string with toString(<radix>) or a number toNumber(). Once digest() has been called, the object can be reused. The same seed will be used or it can be changed with init(<seed>).

Methods

  • XXH.h32() .init(<seed>) Initialize the XXH object with the given seed. The seed can either be a number or a UINT32 object. .update(<data>) Add data for hashing. The data can either be a string, an ArrayBuffer or a NodeJS Buffer object.

  • digest() (UINT32) Finalize the hash calculations and returns an UINT32 object. The hash value can be retrieved with toString().

  • XXH.h64() .init(<seed>) Initialize the XXH object with the given seed. The seed can either be a number or a UINT64 object. .update(<data>) Add data for hashing. The data can either be a string, an ArrayBuffer or a NodeJS Buffer object. * .digest() (UINT64) Finalize the hash calculations and returns an UINT64 object. The hash value can be retrieved with toString().

License

MIT

@ts-actually-safe/collections@sirius-black/taro-clipronote-api@joseirrazabal/kitmenlolab-runnersxyj_taro_clidrill4js-cli@dorian-eydoux/pronote-api@bugsounet/pronote-apibuildepesto-jango@everything-registry/sub-chunk-3192hash-request-cachejdo-api-modulejdseal-clikryoslz4lz4-wallabies-forklz4soulsideluxannas-spellbookhantil-csshyperplexerlearnpacklight-cyclekitado-js@alamar/kit@charlytoc/learnpack@chainx/util-crypto@chainx-v2/crypto@chainx-v2/util-crypto@brigad/ideal-image-loader@bobo-wallet/coin-lib@blakearoberts/ldragon@brad-jones/tsos-cli@ts-std/collections@axiasolar-js/util-crypto@axiacoin/util-crypto@axiasolar/util-crypto@axia-js/util-crypto@authereum/utils@core-server/http@contensis/html-canvas@d-bigfish/cli@drill4j/js-auto-test-agent@drill4j/js-parser@dotenvx/dotenvx@dust-defi/util-crypto@elegy7/parcel-plugin-svg-sprite@dymp/dylphin-cli@etomon/ioredisdown@epimodev/sarv@enirisdev/angular-google-charts@entrylabs/postcss-url@fangchan/taro-cli@gotoeasy/hash@gift-adv/taro-cli@harrysong/cli@fhyx/stores@flatfishjs/cli@flatjs/forge-plugin-postcss-assets@flatjs/forge-postcss-plugin-assets@freik/audiodb@gtarojs/cli@jtma/cli@learnpack/learnpackjs-stl-polyfillelm-factoryencode-passphrasefilruferrumfirebunfission-bloom-filtersopensoc-uioo7-polkadotoo7-substratengrabnullbase-coreng-search-dropdownmps-climstoragepolkadashpolltergeistmeta.macromehdiltgapimaximemaiorespara-scriptsparcel-plugin-svg-spritepostcss-urlpronote-api-againpronote-api-maintainedpronoteapi-atriumfixreact-app-rewire-multiple-entryreact-app-rewire-multiple-entry-extendedreconcile-setsredux-cancelable-requesttarojs-clisvg-sprite-html-webpacktop-sdk-jstop-sdk-js-v2toulouse
0.2.2

6 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago