{"id":13484932,"url":"https://github.com/Daninet/hash-wasm","last_synced_at":"2025-03-27T16:31:38.157Z","repository":{"id":37260980,"uuid":"254565236","full_name":"Daninet/hash-wasm","owner":"Daninet","description":"Lightning fast hash functions using hand-tuned WebAssembly binaries","archived":false,"fork":false,"pushed_at":"2023-11-13T19:16:40.000Z","size":1093,"stargazers_count":879,"open_issues_count":10,"forks_count":49,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-10-29T23:50:03.221Z","etag":null,"topics":["argon2","bcrypt","browser","fast","hash","hmac","javascript","keccak","md5","pbkdf2","scrypt","sha1","sha256","sha3","sha512","sm3","typescript","wasm","webassembly","xxhash"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/hash-wasm","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Daninet.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-04-10T06:52:55.000Z","updated_at":"2024-10-29T05:41:13.000Z","dependencies_parsed_at":"2023-11-13T20:27:40.036Z","dependency_job_id":"f0fcb4fc-9b42-4e5e-814a-16a9de383f67","html_url":"https://github.com/Daninet/hash-wasm","commit_stats":{"total_commits":325,"total_committers":2,"mean_commits":162.5,"dds":"0.012307692307692353","last_synced_commit":"bd3a205ca5603fc80adf71d0966fc72e8d4fa0ef"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daninet%2Fhash-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daninet%2Fhash-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daninet%2Fhash-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daninet%2Fhash-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Daninet","download_url":"https://codeload.github.com/Daninet/hash-wasm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222285209,"owners_count":16960945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argon2","bcrypt","browser","fast","hash","hmac","javascript","keccak","md5","pbkdf2","scrypt","sha1","sha256","sha3","sha512","sm3","typescript","wasm","webassembly","xxhash"],"created_at":"2024-07-31T17:01:39.217Z","updated_at":"2025-03-27T16:31:38.124Z","avatar_url":"https://github.com/Daninet.png","language":"TypeScript","readme":"# hash-wasm\n\n[![npm package](https://img.shields.io/npm/v/hash-wasm.svg)](http://npmjs.org/package/hash-wasm)\n[![Bundle size](https://badgen.net/bundlephobia/minzip/hash-wasm)](https://bundlephobia.com/result?p=hash-wasm)\n[![codecov](https://codecov.io/gh/Daninet/hash-wasm/branch/master/graph/badge.svg)](https://codecov.io/gh/Daninet/hash-wasm)\n[![Build status](https://github.com/Daninet/hash-wasm/workflows/Build%20\u0026%20publish/badge.svg?branch=master)](https://github.com/Daninet/hash-wasm/actions)\n[![JSDelivr downloads](https://data.jsdelivr.com/v1/package/npm/hash-wasm/badge)](https://www.jsdelivr.com/package/npm/hash-wasm)\n\nHash-WASM is a ⚡lightning fast⚡ hash function library for browsers and Node.js.\nIt is using hand-tuned WebAssembly binaries to calculate the hash faster than other libraries.\n\n# Supported algorithms\n\n| Name                                           | Bundle size (gzipped) |\n| ---------------------------------------------- | --------------------- |\n| Adler-32                                       | 3 kB                  |\n| Argon2: Argon2d, Argon2i, Argon2id (v1.3)      | 11 kB                 |\n| bcrypt                                         | 11 kB                 |\n| BLAKE2b                                        | 6 kB                  |\n| BLAKE2s                                        | 5 kB                  |\n| BLAKE3                                         | 9 kB                  |\n| CRC32                                          | 3 kB                  |\n| CRC64                                          | 4 kB                  |\n| HMAC                                           | -                     |\n| MD4                                            | 4 kB                  |\n| MD5                                            | 4 kB                  |\n| PBKDF2                                         | -                     |\n| RIPEMD-160                                     | 5 kB                  |\n| scrypt                                         | 10 kB                 |\n| SHA-1                                          | 5 kB                  |\n| SHA-2: SHA-224, SHA-256                        | 7 kB                  |\n| SHA-2: SHA-384, SHA-512                        | 8 kB                  |\n| SHA-3: SHA3-224, SHA3-256, SHA3-384, SHA3-512  | 4 kB                  |\n| Keccak-224, Keccak-256, Keccak-384, Keccak-512 | 4 kB                  |\n| SM3                                            | 4 kB                  |\n| Whirlpool                                      | 6 kB                  |\n| xxHash32                                       | 3 kB                  |\n| xxHash64                                       | 4 kB                  |\n| xxHash3                                        | 7 kB                  |\n| xxHash128                                      | 8 kB                  |\n\n# Features\n\n- A lot faster than other JS / WASM implementations (see [benchmarks](#benchmark) below)\n- It's lightweight. See the table above\n- Compiled from heavily optimized algorithms written in C\n- Supports all modern browsers, Node.js and Deno\n- Supports large data streams\n- Supports UTF-8 strings and typed arrays\n- Supports chunked input streams\n- Modular architecture (the algorithms are compiled into individual WASM binaries)\n- WASM modules are bundled as base64 strings (no problems with linking)\n- Supports tree shaking (Webpack only bundles the hash algorithms you use)\n- Works without Webpack or other bundlers\n- Includes TypeScript type definitions\n- Works in Web Workers\n- Zero dependencies\n- Supports concurrent hash calculations with multiple states\n- Supports saving and loading the internal state of the hash (segmented hashing and rewinding)\n- [Unit tests](https://github.com/Daninet/hash-wasm/tree/master/test) for all algorithms\n- 100% open source \u0026 transparent [build process](https://github.com/Daninet/hash-wasm/actions)\n- Easy to use, Promise-based API\n\n# Installation\n\n```\nnpm i hash-wasm\n```\n\nIt can also be used directly from HTML (via [jsDelivr](https://www.jsdelivr.com/package/npm/hash-wasm)):\n\n```html\n\u003c!-- load all algortihms into the global `hashwasm` variable --\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/hash-wasm@4\"\u003e\u003c/script\u003e\n\n\u003c!-- load individual algortihms into the global `hashwasm` variable --\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/hash-wasm@4/dist/md5.umd.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/hash-wasm@4/dist/hmac.umd.min.js\"\u003e\u003c/script\u003e\n```\n\n# Examples\n\n### Demo apps\n\n[Hash calculator](https://3w4be.csb.app/) - [source code](https://codesandbox.io/s/hash-wasm-3w4be?file=/src/App.tsx)\n\n[MD5 file hasher using HTML5 File API](https://stackoverflow.com/a/63287199/6251760)\n\n### Usage with the shorthand form\n\nIt is the easiest and the fastest way to calculate hashes. Use it when the input buffer is already in the memory.\n\n```javascript\nimport { md5, sha1, sha512, sha3 } from \"hash-wasm\";\n\nasync function run() {\n  console.log(\"MD5:\", await md5(\"demo\"));\n\n  const int8Buffer = new Uint8Array([0, 1, 2, 3]);\n  console.log(\"SHA1:\", await sha1(int8Buffer));\n  console.log(\"SHA512:\", await sha512(int8Buffer));\n\n  const int32Buffer = new Uint32Array([1056, 641]);\n  console.log(\"SHA3-256:\", await sha3(int32Buffer, 256));\n}\n\nrun();\n```\n\n_\\* See [String encoding pitfalls](#string-encoding-pitfalls)_\n\n_\\*\\* See [API reference](#api)_\n\n### Advanced usage with streaming input\n\ncreateXXXX() functions create new WASM instances with separate states, which can be used to calculate multiple hashes paralelly. They are slower compared to shorthand functions like md5(), which reuse the same WASM instance and state to do multiple calculations. For this reason, the shorthand form is always preferred when the data is already in the memory.\n\nFor the best performance, avoid calling createXXXX() functions in loops. When calculating multiple hashes sequentially, the init() function can be used to reset the internal state between runs. It is faster than creating new instances with createXXXX().\n\n```javascript\nimport { createSHA1 } from \"hash-wasm\";\n\nasync function run() {\n  const sha1 = await createSHA1();\n  sha1.init();\n\n  while (hasMoreData()) {\n    const chunk = readChunk();\n    sha1.update(chunk);\n  }\n\n  const hash = sha1.digest(\"binary\"); // returns Uint8Array\n  console.log(\"SHA1:\", hash);\n}\n\nrun();\n```\n\n_\\* See [String encoding pitfalls](#string-encoding-pitfalls)_\n\n_\\*\\* See [API reference](#api)_\n\n### Hashing passwords with Argon2\n\nThe recommended process for choosing the parameters can be found here: https://tools.ietf.org/html/draft-irtf-cfrg-argon2-04#section-4\n\n```javascript\nimport { argon2id, argon2Verify } from \"hash-wasm\";\n\nasync function run() {\n  const salt = new Uint8Array(16);\n  window.crypto.getRandomValues(salt);\n\n  const key = await argon2id({\n    password: \"pass\",\n    salt, // salt is a buffer containing random bytes\n    parallelism: 1,\n    iterations: 256,\n    memorySize: 512, // use 512KB memory\n    hashLength: 32, // output size = 32 bytes\n    outputType: \"encoded\", // return standard encoded string containing parameters needed to verify the key\n  });\n\n  console.log(\"Derived key:\", key);\n\n  const isValid = await argon2Verify({\n    password: \"pass\",\n    hash: key,\n  });\n\n  console.log(isValid ? \"Valid password\" : \"Invalid password\");\n}\n\nrun();\n```\n\n_\\* See [String encoding pitfalls](#string-encoding-pitfalls)_\n\n_\\*\\* See [API reference](#api)_\n\n### Hashing passwords with bcrypt\n\n```javascript\nimport { bcrypt, bcryptVerify } from \"hash-wasm\";\n\nasync function run() {\n  const salt = new Uint8Array(16);\n  window.crypto.getRandomValues(salt);\n\n  const key = await bcrypt({\n    password: \"pass\",\n    salt, // salt is a buffer containing 16 random bytes\n    costFactor: 11,\n    outputType: \"encoded\", // return standard encoded string containing parameters needed to verify the key\n  });\n\n  console.log(\"Derived key:\", key);\n\n  const isValid = await bcryptVerify({\n    password: \"pass\",\n    hash: key,\n  });\n\n  console.log(isValid ? \"Valid password\" : \"Invalid password\");\n}\n\nrun();\n```\n\n_\\* See [String encoding pitfalls](#string-encoding-pitfalls)_\n\n_\\*\\* See [API reference](#api)_\n\n### Calculating HMAC\n\nAll supported hash functions can be used to calculate HMAC. For the best performance, avoid calling createXXXX() in loops (see `Advanced usage with streaming input` section above)\n\n```javascript\nimport { createHMAC, createSHA3 } from \"hash-wasm\";\n\nasync function run() {\n  const hashFunc = createSHA3(224); // SHA3-224\n  const hmac = await createHMAC(hashFunc, \"key\");\n\n  const fruits = [\"apple\", \"raspberry\", \"watermelon\"];\n  console.log(\"Input:\", fruits);\n\n  const codes = fruits.map((data) =\u003e {\n    hmac.init();\n    hmac.update(data);\n    return hmac.digest();\n  });\n\n  console.log(\"HMAC:\", codes);\n}\n\nrun();\n```\n\n_\\* See [String encoding pitfalls](#string-encoding-pitfalls)_\n\n_\\*\\* See [API reference](#api)_\n\n### Calculating PBKDF2\n\nAll supported hash functions can be used to calculate PBKDF2. For the best performance, avoid calling createXXXX() in loops (see `Advanced usage with streaming input` section above)\n\n```javascript\nimport { pbkdf2, createSHA1 } from \"hash-wasm\";\n\nasync function run() {\n  const salt = new Uint8Array(16);\n  window.crypto.getRandomValues(salt);\n\n  const key = await pbkdf2({\n    password: \"password\",\n    salt,\n    iterations: 1000,\n    hashLength: 32,\n    hashFunction: createSHA1(),\n    outputType: \"hex\",\n  });\n\n  console.log(\"Derived key:\", key);\n}\n\nrun();\n```\n\n_\\* See [String encoding pitfalls](#string-encoding-pitfalls)_\n\n_\\*\\* See [API reference](#api)_\n\n### String encoding pitfalls\n\nYou should be aware that there may be multiple UTF-8 representations of a given string:\n\n```js\n\"\\u00fc\"; // encodes the ü character\n\"u\\u0308\"; // also encodes the ü character\n\n\"\\u00fc\" === \"u\\u0308\"; // false\n\"ü\" === \"ü\"; // false\n```\n\nAll algorithms defined in this library depend on the binary representation of the input string. Thus, it's highly recommended to normalize your strings before passing it to hash-wasm. You can use the `normalize()` built-in String function to archive this:\n\n```js\n\"\\u00fc\".normalize() === \"u\\u0308\".normalize(); // true\n\nconst te = new TextEncoder();\nte.encode(\"u\\u0308\"); // Uint8Array(3) [117, 204, 136]\nte.encode(\"\\u00fc\"); // Uint8Array(2) [195, 188]\n\nte.encode(\"u\\u0308\".normalize(\"NFKC\")); // Uint8Array(2) [195, 188]\nte.encode(\"\\u00fc\".normalize(\"NFKC\")); // Uint8Array(2) [195, 188]\n```\n\nYou can read more about this issue here: https://en.wikipedia.org/wiki/Unicode_equivalence\n\n### Resumable hashing\n\nYou can save the current internal state of the hash using the `.save()` function. This state may be written to disk or stored elsewhere in memory.\nYou can then use the `.load(state)` function to reload that state into a new instance of the hash, or back into the same instance.\n\nThis allows you to span the work of hashing a file across multiple processes (e.g. in environments with limited execution times like AWS Lambda, where large jobs need to be split across multiple invocations), or rewind the hash to an earlier point in the stream. For example, the first process could:\n\n```js\n// first process starts hashing\nconst md5 = await createMD5();\nmd5.init();\nmd5.update(\"Hello, \");\nconst state = md5.save(); // save this state\n\n// second process resumes hashing from the stored state\nconst md5 = await createMD5();\nmd5.load(state);\nmd5.update(\"world!\");\nconsole.log(md5.digest()); // Prints 6cd3556deb0da54bca060b4c39479839 = md5(\"Hello, world!\")\n```\n\n_Note that both the saving and loading processes must be running compatible versions of the hash function (i.e. the hash function hasn't changed between the versions of hash-wasm used in the saving and loading processes). If the saved state is incompatible, `load()` will throw an exception._\n\n_The saved state can contain information about the input, including plaintext input bytes, so from a security perspective it must be treated with the same care as the input data itself._\n\n\u003cbr/\u003e\n\n# Browser support\n\n\u003cbr/\u003e\n\n| Chrome | Safari | Firefox | Edge | IE            | Node.js | Deno |\n| ------ | ------ | ------- | ---- | ------------- | ------- | ---- |\n| 57+    | 11+    | 53+     | 16+  | Not supported | 8+      | 1+   |\n\n\u003cbr/\u003e\n\n# Benchmark\n\nYou can make your own measurements here: [link](https://daninet.github.io/hash-wasm-benchmark/)\n\nTwo scenarios were measured:\n\n- throughput with the short form (input size = 32 bytes)\n- throughput with the short form (input size = 1MB)\n\nResults:\n\n| MD5                         | throughput (32 bytes) | throughput (1MB) |\n| --------------------------- | --------------------- | ---------------- |\n| **hash-wasm 4.10.0**        | **110.52 MB/s**       | **850.31 MB/s**  |\n| spark-md5 3.0.2 (from npm)  | 38.87 MB/s            | 171.73 MB/s      |\n| md5-wasm 2.0.0 (from npm)   | 37.36 MB/s            | 131.77 MB/s      |\n| crypto-js 4.1.1 (from npm)  | 9.30 MB/s             | 46.71 MB/s       |\n| node-forge 1.3.1 (from npm) | 18.23 MB/s            | 28.94 MB/s       |\n| md5 2.3.0 (from npm)        | 14.50 MB/s            | 21.65 MB/s       |\n\n#\n\n| SHA1                        | throughput (32 bytes) | throughput (1MB) |\n| --------------------------- | --------------------- | ---------------- |\n| **hash-wasm 4.10.0**        | **83.80 MB/s**        | **798.19 MB/s**  |\n| jsSHA 3.3.1 (from npm)      | 34.93 MB/s            | 78.12 MB/s       |\n| crypto-js 4.1.1 (from npm)  | 9.50 MB/s             | 69.02 MB/s       |\n| node-forge 1.3.1 (from npm) | 17.02 MB/s            | 32.00 MB/s       |\n| sha1 1.1.1 (from npm)       | 14.68 MB/s            | 24.24 MB/s       |\n\n#\n\n| SHA256                        | throughput (32 bytes) | throughput (1MB) |\n| ----------------------------- | --------------------- | ---------------- |\n| **hash-wasm 4.10.0**          | **63.99 MB/s**        | **426.16 MB/s**  |\n| sha256-wasm 2.2.2 (from npm)  | 20.37 MB/s            | 308.39 MB/s      |\n| noble-hashes 1.3.2 (from npm) | 24.73 MB/s            | 110.02 MB/s      |\n| crypto-js 4.1.1 (from npm)    | 8.99 MB/s             | 65.17 MB/s       |\n| jsSHA 3.3.1 (from npm)        | 25.64 MB/s            | 57.98 MB/s       |\n| node-forge 1.3.1 (from npm)   | 13.93 MB/s            | 28.19 MB/s       |\n\n#\n\n| SHA3-512                      | throughput (32 bytes) | throughput (1MB) |\n| ----------------------------- | --------------------- | ---------------- |\n| **hash-wasm 4.10.0**          | **38.06 MB/s**        | **234.40 MB/s**  |\n| sha3-wasm 1.0.0 (from npm)    | 15.44 MB/s            | 101.51 MB/s      |\n| noble-hashes 1.3.2 (from npm) | 5.74 MB/s             | 14.19 MB/s       |\n| sha3 2.1.4 (from npm)         | 3.80 MB/s             | 10.73 MB/s       |\n| jsSHA 3.2.0 (from npm)        | 2.08 MB/s             | 3.82 MB/s        |\n\n#\n\n| XXHash64                     | throughput (32 bytes) | throughput (1MB)   |\n| ---------------------------- | --------------------- | ------------------ |\n| **hash-wasm 4.10.0**         | **101.66 MB/s**       | **15 989 MB/s** |\n| xxhash-wasm 1.0.2 (from npm) | 47.58 MB/s            | 15 929 MB/s     |\n| xxhashjs 0.2.2 (from npm)    | 0.92 MB/s             | 42.26 MB/s         |\n\n#\n\n| PBKDF2-SHA512 - 1000 iterations | operations per second (16 bytes) |\n| ------------------------------- | -------------------------------- |\n| **hash-wasm 4.10.0**            | **588 ops**                      |\n| noble-hashes 1.3.2 (from npm)   | 395 ops                          |\n| pbkdf2 3.1.2 (from npm)         | 83 ops                           |\n| crypto-js 4.1.1 (from npm)      | 29 ops                           |\n\n#\n\n| Argon2id (m=512, t=8, p=1)       | operations per second (16 bytes) |\n| -------------------------------- | -------------------------------- |\n| **hash-wasm 4.10.0**             | **438 ops**                      |\n| argon2-browser 1.18.0 (from npm) | 213 ops                          |\n| argon2-wasm-pro 1.1.0 (from npm) | 203 ops                          |\n| argon2-wasm 0.9.0 (from npm)     | 195 ops                          |\n\n\u003cbr/\u003e\n\n\\* These measurements were made with `Chrome v131` on a Ryzen 9 7900X desktop CPU.\n\n# API\n\n```ts\ntype IDataType = string | Buffer | Uint8Array | Uint16Array | Uint32Array;\n\n// all functions return hash in hex format\nadler32(data: IDataType): Promise\u003cstring\u003e\nblake2b(data: IDataType, bits?: number, key?: IDataType): Promise\u003cstring\u003e // default is 512 bits\nblake2s(data: IDataType, bits?: number, key?: IDataType): Promise\u003cstring\u003e // default is 256 bits\nblake3(data: IDataType, bits?: number, key?: IDataType): Promise\u003cstring\u003e // default is 256 bits\ncrc32(data: IDataType, polynomial?: number): Promise\u003cstring\u003e // default polynomial is 0xedb88320, for CRC32C use 0x82f63b78\ncrc64(data: IDataType, polynomial?: string): Promise\u003cstring\u003e // default polynomial is 'c96c5795d7870f42' (ECMA)\nkeccak(data: IDataType, bits?: 224 | 256 | 384 | 512): Promise\u003cstring\u003e // default is 512 bits\nmd4(data: IDataType): Promise\u003cstring\u003e\nmd5(data: IDataType): Promise\u003cstring\u003e\nripemd160(data: IDataType): Promise\u003cstring\u003e\nsha1(data: IDataType): Promise\u003cstring\u003e\nsha224(data: IDataType): Promise\u003cstring\u003e\nsha256(data: IDataType): Promise\u003cstring\u003e\nsha3(data: IDataType, bits?: 224 | 256 | 384 | 512): Promise\u003cstring\u003e // default is 512 bits\nsha384(data: IDataType): Promise\u003cstring\u003e\nsha512(data: IDataType): Promise\u003cstring\u003e\nsm3(data: IDataType): Promise\u003cstring\u003e\nwhirlpool(data: IDataType): Promise\u003cstring\u003e\nxxhash32(data: IDataType, seed?: number): Promise\u003cstring\u003e\nxxhash64(data: IDataType, seedLow?: number, seedHigh?: number): Promise\u003cstring\u003e\nxxhash3(data: IDataType, seedLow?: number, seedHigh?: number): Promise\u003cstring\u003e\nxxhash128(data: IDataType, seedLow?: number, seedHigh?: number): Promise\u003cstring\u003e\n\ninterface IHasher {\n  init: () =\u003e IHasher;\n  update: (data: IDataType) =\u003e IHasher;\n  digest: (outputType: 'hex' | 'binary') =\u003e string | Uint8Array; // by default returns hex string\n  save: () =\u003e Uint8Array; // returns the internal state for later resumption\n  load: (state: Uint8Array) =\u003e IHasher; // loads a previously saved internal state\n  blockSize: number; // in bytes\n  digestSize: number; // in bytes\n}\n\ncreateAdler32(): Promise\u003cIHasher\u003e\ncreateBLAKE2b(bits?: number, key?: IDataType): Promise\u003cIHasher\u003e // default is 512 bits\ncreateBLAKE2s(bits?: number, key?: IDataType): Promise\u003cIHasher\u003e // default is 256 bits\ncreateBLAKE3(bits?: number, key?: IDataType): Promise\u003cIHasher\u003e // default is 256 bits\ncreateCRC32(polynomial?: number): Promise\u003cIHasher\u003e // default polynomial is 0xedb88320, for CRC32C use 0x82f63b78\ncreateCRC64(polynomial?: number): Promise\u003cIHasher\u003e // default polynomial is 'c96c5795d7870f42' (ECMA)\ncreateKeccak(bits?: 224 | 256 | 384 | 512): Promise\u003cIHasher\u003e // default is 512 bits\ncreateMD4(): Promise\u003cIHasher\u003e\ncreateMD5(): Promise\u003cIHasher\u003e\ncreateRIPEMD160(): Promise\u003cIHasher\u003e\ncreateSHA1(): Promise\u003cIHasher\u003e\ncreateSHA224(): Promise\u003cIHasher\u003e\ncreateSHA256(): Promise\u003cIHasher\u003e\ncreateSHA3(bits?: 224 | 256 | 384 | 512): Promise\u003cIHasher\u003e // default is 512 bits\ncreateSHA384(): Promise\u003cIHasher\u003e\ncreateSHA512(): Promise\u003cIHasher\u003e\ncreateSM3(): Promise\u003cIHasher\u003e\ncreateWhirlpool(): Promise\u003cIHasher\u003e\ncreateXXHash32(seed: number): Promise\u003cIHasher\u003e\ncreateXXHash64(seedLow: number, seedHigh: number): Promise\u003cIHasher\u003e\ncreateXXHash3(seedLow: number, seedHigh: number): Promise\u003cIHasher\u003e\ncreateXXHash128(seedLow: number, seedHigh: number): Promise\u003cIHasher\u003e\n\ncreateHMAC(hashFunction: Promise\u003cIHasher\u003e, key: IDataType): Promise\u003cIHasher\u003e\n\npbkdf2({\n  password: IDataType, // password (or message) to be hashed\n  salt: IDataType, // salt (usually containing random bytes)\n  iterations: number, // number of iterations to perform\n  hashLength: number, // output size in bytes\n  hashFunction: Promise\u003cIHasher\u003e, // the return value of a function like createSHA1()\n  outputType?: 'hex' | 'binary', // by default returns hex string\n}): Promise\u003cstring | Uint8Array\u003e\n\nscrypt({\n  password: IDataType, // password (or message) to be hashed\n  salt: IDataType, // salt (usually containing random bytes)\n  costFactor: number, // CPU/memory cost - must be a power of 2 (e.g. 1024)\n  blockSize: number, // block size parameter (8 is commonly used)\n  parallelism: number, // degree of parallelism\n  hashLength: number, // output size in bytes\n  outputType?: 'hex' | 'binary', // by default returns hex string\n}): Promise\u003cstring | Uint8Array\u003e\n\ninterface IArgon2Options {\n  password: IDataType; // password (or message) to be hashed\n  salt: IDataType; // salt (usually containing random bytes)\n  secret?: IDataType; // secret for keyed hashing\n  iterations: number; // number of iterations to perform\n  parallelism: number; // degree of parallelism\n  memorySize: number; // amount of memory to be used in kibibytes (1024 bytes)\n  hashLength: number; // output size in bytes\n  outputType?: 'hex' | 'binary' | 'encoded'; // by default returns hex string\n}\n\nargon2i(options: IArgon2Options): Promise\u003cstring | Uint8Array\u003e\nargon2d(options: IArgon2Options): Promise\u003cstring | Uint8Array\u003e\nargon2id(options: IArgon2Options): Promise\u003cstring | Uint8Array\u003e\n\nargon2Verify({\n  password: IDataType, // password\n  secret?: IDataType, // secret used on hash creation\n  hash: string, // encoded hash\n}): Promise\u003cboolean\u003e\n\nbcrypt({\n  password: IDataType, // password\n  salt: IDataType, // salt (16 bytes long - usually containing random bytes)\n  costFactor: number, // number of iterations to perform (4 - 31)\n  outputType?: 'hex' | 'binary' | 'encoded', // by default returns encoded string\n}): Promise\u003cstring | Uint8Array\u003e\n\nbcryptVerify({\n  password: IDataType, // password\n  hash: string, // encoded hash\n}): Promise\u003cboolean\u003e\n\n```\n\n# Future plans\n\n- Add more well-known algorithms\n- Write a polyfill which keeps bundle sizes low and enables running binaries containing newer WASM instructions\n- Use WebAssembly Bulk Memory Operations\n- Use WebAssembly SIMD instructions (expecting a 10-20% performance increase)\n- Enable multithreading where it's possible (like at Argon2)\n","funding_links":[],"categories":["TypeScript","Misc","javascript","typescript","browser"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDaninet%2Fhash-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDaninet%2Fhash-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDaninet%2Fhash-wasm/lists"}