{"_id":"tinymask-js","name":"tinymask-js","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.2":{"name":"tinymask-js","version":"1.0.2","description":"tinymask-js","main":"index.js","types":"index.d.ts","license":"MIT","dependencies":{"tinymask":"*"},"_id":"tinymask-js@1.0.2","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-3Js9ZugHE3tA61yNNVMr0n2cZb23Gdft9bViExM/BU2EaFoH8jbVUgBSrs9RsKq8ht1YIZHKhk4eBqn6c3DQRg==","shasum":"5bd023bac45804f8ce26949a293cdec5cc85742b","tarball":"https://registry.npmjs.org/tinymask-js/-/tinymask-js-1.0.2.tgz","fileCount":4,"unpackedSize":10794,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIG3pFh1xU3U7ZGQk/YV5y7SneObFe4+PkHmbH8r/1PfkAiEAhheiuDaOWC+OLemMNcdEGXXI0Uy9P7Pf7EUc0u7DvpM="}]},"_npmUser":{"name":"kassyd3","email":"stephendavidso.n3.59.45@gmail.com"},"directories":{},"maintainers":[{"name":"kassyd3","email":"stephendavidso.n3.59.45@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tinymask-js_1.0.2_1783698961981_0.5904578729061027"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-10T15:56:01.933Z","1.0.2":"2026-07-10T15:56:02.126Z","modified":"2026-07-10T15:56:02.353Z"},"maintainers":[{"name":"kassyd3","email":"stephendavidso.n3.59.45@gmail.com"}],"description":"tinymask-js","license":"MIT","readme":"# bcrypt.js\n\n\nOptimized bcrypt in JavaScript with zero dependencies, with TypeScript support. Compatible to the C++\n\n[bcrypt](https://npmjs.org/package/bcrypt) binding on Node.js and also working in the browser.\n\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/dcodeIO/bcrypt.js/test.yml?branch=main&label=test&logo=github)](https://github.com/dcodeIO/bcrypt.js/actions/workflows/test.yml) [![Publish Status](https://img.shields.io/github/actions/workflow/status/dcodeIO/bcrypt.js/publish.yml?branch=main&label=publish&logo=github)](https://github.com/dcodeIO/bcrypt.js/actions/workflows/publish.yml) [![npm](https://img.shields.io/npm/v/bcryptjs.svg?label=npm&color=007acc&logo=npm)](https://www.npmjs.com/package/bcryptjs)\n\n\n## Security considerations\n\n\nBesides incorporating a salt to protect against rainbow table attacks, bcrypt is an adaptive function: over time, the\n\niteration count can be increased to make it slower, so it remains resistant to brute-force search attacks even with\n\nincreasing computation power. ([see](http://en.wikipedia.org/wiki/Bcrypt))\n\n\nWhile bcrypt.js is compatible to the C++ bcrypt binding, it is written in pure JavaScript and thus slower ([about 30%](https://github.com/dcodeIO/bcrypt.js/wiki/Benchmark)), effectively reducing the number of iterations that can be\n\nprocessed in an equal time span.\n\n\nThe maximum input length is 72 bytes (note that UTF-8 encoded characters use up to 4 bytes) and the length of generated\n\nhashes is 60 characters. Note that maximum input length is not implicitly checked by the library for compatibility with\n\nthe C++ binding on Node.js, but should be checked with `bcrypt.truncates(password)` where necessary.\n\n\n## Usage\n\n\nThe package exports an ECMAScript module with an UMD fallback.\n\n\n```\n\n$> npm install bcryptjs\n\n```\n\n\n```ts\n\nimport bcrypt from \"bcryptjs\";\n\n```\n\n\n### Usage with a CDN\n\n\n- From GitHub via [jsDelivr](https://www.jsdelivr.com):<br />\n\n  `https://cdn.jsdelivr.net/gh/dcodeIO/bcrypt.js@TAG/index.js` (ESM)\n\n- From npm via [jsDelivr](https://www.jsdelivr.com):<br />\n\n  `https://cdn.jsdelivr.net/npm/bcryptjs@VERSION/index.js` (ESM)<br />\n\n  `https://cdn.jsdelivr.net/npm/bcryptjs@VERSION/umd/index.js` (UMD)\n\n- From npm via [unpkg](https://unpkg.com):<br />\n\n  `https://unpkg.com/bcryptjs@VERSION/index.js` (ESM)<br />\n\n  `https://unpkg.com/bcryptjs@VERSION/umd/index.js` (UMD)\n\n\nReplace `TAG` respectively `VERSION` with a [specific version](https://github.com/dcodeIO/bcrypt.js/releases) or omit it (not recommended in production) to use latest.\n\n\nWhen using the ESM variant in a browser, the `crypto` import needs to be stubbed out, for example using an [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap). Bundlers should omit it automatically.\n\n\n### Usage - Sync\n\n\nTo hash a password:\n\n\n```ts\n\nconst salt = bcrypt.genSaltSync(10);\n\nconst hash = bcrypt.hashSync(\"B4c0/\\/\", salt);\n\n// Store hash in your password DB\n\n```\n\n\nTo check a password:\n\n\n```ts\n\n// Load hash from your password DB\n\nbcrypt.compareSync(\"B4c0/\\/\", hash); // true\n\nbcrypt.compareSync(\"not_bacon\", hash); // false\n\n```\n\n\nAuto-gen a salt and hash:\n\n\n```ts\n\nconst hash = bcrypt.hashSync(\"bacon\", 10);\n\n```\n\n\n### Usage - Async\n\n\nTo hash a password:\n\n\n```ts\n\nconst salt = await bcrypt.genSalt(10);\n\nconst hash = await bcrypt.hash(\"B4c0/\\/\", salt);\n\n// Store hash in your password DB\n\n```\n\n\n```ts\n\nbcrypt.genSalt(10, (err, salt) => {\n\n  bcrypt.hash(\"B4c0/\\/\", salt, function (err, hash) {\n\n    // Store hash in your password DB\n\n  });\n\n});\n\n```\n\n\nTo check a password:\n\n\n```ts\n\n// Load hash from your password DB\n\nawait bcrypt.compare(\"B4c0/\\/\", hash); // true\n\nawait bcrypt.compare(\"not_bacon\", hash); // false\n\n```\n\n\n```ts\n\n// Load hash from your password DB\n\nbcrypt.compare(\"B4c0/\\/\", hash, (err, res) => {\n\n  // res === true\n\n});\n\nbcrypt.compare(\"not_bacon\", hash, (err, res) => {\n\n  // res === false\n\n});\n\n```\n\n\nAuto-gen a salt and hash:\n\n\n```ts\n\nawait bcrypt.hash(\"B4c0/\\/\", 10);\n\n// Store hash in your password DB\n\n```\n\n\n```ts\n\nbcrypt.hash(\"B4c0/\\/\", 10, (err, hash) => {\n\n  // Store hash in your password DB\n\n});\n\n```\n\n\n**Note:** Under the hood, asynchronous APIs split an operation into small chunks. After the completion of a chunk, the execution of the next chunk is placed on the back of the [JS event queue](https://developer.mozilla.org/en/docs/Web/JavaScript/EventLoop), efficiently yielding for other computation to execute.\n\n\n### Usage - Command Line\n\n\n```\n\nUsage: bcrypt <input> [rounds|salt]\n\n```\n\n\n## API\n\n\n### Callback types\n\n\n- **Callback<`T`>**: `(err: Error | null, result?: T) => void`<br />\n\n  Called with an error on failure or a value of type `T` upon success.\n\n\n- **ProgressCallback**: `(percentage: number) => void`<br />\n\n  Called with the percentage of rounds completed (0.0 - 1.0), maximally once per `MAX_EXECUTION_TIME = 100` ms.\n\n\n- **RandomFallback**: `(length: number) => number[]`<br />\n\n  Called to obtain random bytes when both [Web Crypto API](http://www.w3.org/TR/WebCryptoAPI/) and Node.js\n\n  [crypto](http://nodejs.org/api/crypto.html) are not available.\n\n\n### Functions\n\n\n- bcrypt.**genSaltSync**(rounds?: `number`): `string`<br />\n\n  Synchronously generates a salt. Number of rounds defaults to 10 when omitted.\n\n\n- bcrypt.**genSalt**(rounds?: `number`): `Promise<string>`<br />\n\n  Asynchronously generates a salt. Number of rounds defaults to 10 when omitted.\n\n\n- bcrypt.**genSalt**([rounds: `number`, ]callback: `Callback<string>`): `void`<br />\n\n  Asynchronously generates a salt. Number of rounds defaults to 10 when omitted.\n\n\n- bcrypt.**truncates**(password: `string`): `boolean`<br />\n\n  Tests if a password will be truncated when hashed, that is its length is greater than 72 bytes when converted to UTF-8.\n\n\n- bcrypt.**hashSync**(password: `string`, salt?: `number | string`): `string`\n\n  Synchronously generates a hash for the given password. Number of rounds defaults to 10 when omitted.\n\n\n- bcrypt.**hash**(password: `string`, salt: `number | string`): `Promise<string>`<br />\n\n  Asynchronously generates a hash for the given password.\n\n\n- bcrypt.**hash**(password: `string`, salt: `number | string`, callback: `Callback<string>`, progressCallback?: `ProgressCallback`): `void`<br />\n\n  Asynchronously generates a hash for the given password.\n\n\n- bcrypt.**compareSync**(password: `string`, hash: `string`): `boolean`<br />\n\n  Synchronously tests a password against a hash.\n\n\n- bcrypt.**compare**(password: `string`, hash: `string`): `Promise<boolean>`<br />\n\n  Asynchronously compares a password against a hash.\n\n\n- bcrypt.**compare**(password: `string`, hash: `string`, callback: `Callback<boolean>`, progressCallback?: `ProgressCallback`)<br />\n\n  Asynchronously compares a password against a hash.\n\n\n- bcrypt.**getRounds**(hash: `string`): `number`<br />\n\n  Gets the number of rounds used to encrypt the specified hash.\n\n\n- bcrypt.**getSalt**(hash: `string`): `string`<br />\n\n  Gets the salt portion from a hash. Does not validate the hash.\n\n\n- bcrypt.**setRandomFallback**(random: `RandomFallback`): `void`<br />\n\n  Sets the pseudo random number generator to use as a fallback if neither [Web Crypto API](http://www.w3.org/TR/WebCryptoAPI/) nor Node.js [crypto](http://nodejs.org/api/crypto.html) are available. Please note: It is highly important that the PRNG used is cryptographically secure and that it is seeded properly!\n\n\n## Building\n\n\nBuilding the UMD fallback:\n\n\n```\n\n$> npm run build\n\n```\n\n\nRunning the [tests](./tests):\n\n\n```\n\n$> npm test\n\n```\n\n\n## Credits\n\n\nBased on work started by Shane Girish at [bcrypt-nodejs](https://github.com/shaneGirish/bcrypt-nodejs), which is itself\n\nbased on [javascript-bcrypt](http://code.google.com/p/javascript-bcrypt/) (New BSD-licensed).\n\n\n","readmeFilename":"README.md","_rev":"1-fb00007e6723bd7ddefc567406b0b781"}