{"name":"bcryptjs","description":"Optimized bcrypt in plain JavaScript with zero dependencies. Compatible to 'bcrypt'.","version":"1.0.3","author":{"name":"Daniel Wirtz","email":"dcode@dcode.io"},"contributors":[{"name":"Shane Girish","email":"shaneGirish@gmail.com","url":"https://github.com/shaneGirish"},{"name":"Alex Murray","url":"https://github.com/alexmurray"},{"name":"Nicolas Pelletier","url":"https://github.com/NicolasPelletier"},{"name":"Josh Rogers","url":"https://github.com/geekymole"},{"name":"Noah Isaacson","email":"noah@nisaacson.com","url":"https://github.com/nisaacson"}],"repository":{"type":"url","url":"https://github.com/dcodeIO/bcrypt.js.git"},"bugs":{"url":"https://github.com/dcodeIO/bcrypt.js/issues"},"keywords":["bcrypt","password","auth","authentication","encryption","crypt","crypto"],"main":"index.js","dependencies":{},"devDependencies":{"testjs":"latest","preprocessor":"latest","closurecompiler":"latest","bcrypt":"latest"},"license":"Apache-2.0","scripts":{"test":"node node_modules/testjs/bin/testjs","build":"preprocess ./src/bcrypt.js ./src > ./dist/bcrypt.js","compile":"ccjs dist/bcrypt.js --compilation_level=ADVANCED_OPTIMIZATIONS --externs=externs/minimal-env.js --output_wrapper=\"(function(){%output%})();\" > dist/bcrypt.min.js","make":"npm run-script build && npm run-script compile && npm test"},"homepage":"https://github.com/dcodeIO/bcrypt.js","_id":"bcryptjs@1.0.3","_shasum":"eefc8503e49221ea3241d7fafb869feeaf4a4c45","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"dcode","email":"dcode@dcode.io"},"maintainers":[{"name":"dcode","email":"dcode@dcode.io"}],"dist":{"shasum":"eefc8503e49221ea3241d7fafb869feeaf4a4c45","size":50439,"noattachment":false,"tarball":"https://registry.npmmirror.com/bcryptjs/-/bcryptjs-1.0.3.tgz","integrity":"sha512-llKb8yW83ZKOsRFOlTGjWl979fFoK2D5kPlONd1oe5vOPRGDbTZX1qVUGt55266QHutQHM4LOBwN8VFXgwn/6Q=="},"directories":{},"publish_time":1403644909343,"_hasShrinkwrap":false,"_cnpm_publish_time":1403644909343,"_cnpmcore_publish_time":"2021-12-16T11:52:30.934Z","readme":"![bcrypt.js - bcrypt in plain JavaScript](https://raw.github.com/dcodeIO/bcrypt.js/master/bcrypt.png)\r\n===========\r\nOptimized bcrypt in plain JavaScript with zero dependencies. Compatible to the C++ [bcrypt](https://npmjs.org/package/bcrypt)\r\nbinding and also working in the browser.\r\n\r\nFeatures ![Build Status](https://travis-ci.org/dcodeIO/bcrypt.js.png?branch=master)\r\n--------\r\n* CommonJS/node.js compatible (via [crypto](http://nodejs.org/api/crypto.html)), also available via [npm](https://npmjs.org/package/bcryptjs) \r\n* Shim/browser compatible (via [WebCryptoAPI](http://www.w3.org/TR/WebCryptoAPI))\r\n* RequireJS/AMD compatible\r\n* Zero production dependencies\r\n* Small footprint\r\n* Compiled with Closure Compiler using advanced optimizations, [externs included](https://github.com/dcodeIO/bcrypt.js/blob/master/externs/bcrypt.js)\r\n\r\nSecurity considerations\r\n-----------------------\r\nBesides incorporating a salt to protect against rainbow table attacks, bcrypt is an adaptive function: over time, the\r\niteration count can be increased to make it slower, so it remains resistant to brute-force search attacks even with\r\nincreasing computation power. ([see](http://en.wikipedia.org/wiki/Bcrypt))\r\n\r\nWhile bcrypt.js is compatible to the C++ bcrypt binding, it is written in pure JavaScript and thus slower, effectively\r\nreducing the number of iterations that can be processed in an equal time span.\r\n\r\nUsage\r\n-----\r\n\r\n#### node.js\r\n`npm install bcryptjs`\r\n\r\n```javascript\r\nvar bcrypt = require('bcryptjs');\r\n...\r\n```\r\n\r\n#### RequireJS/AMD\r\n```javascript\r\nrequire.config({\r\n \"paths\": {\r\n \"bcrypt\": \"/path/to/bcrypt.js\"\r\n }\r\n});\r\nrequire([\"bcrypt\"], function(bcrypt) {\r\n ...\r\n});\r\n```\r\n\r\n#### Shim/browser\r\n```html\r\n\r\n```\r\n```javascript\r\nvar bcrypt = dcodeIO.bcrypt;\r\n...\r\n```\r\n\r\nUsage - Sync\r\n------------\r\nTo hash a password: \r\n\r\n```javascript\r\nvar bcrypt = require('bcryptjs');\r\nvar salt = bcrypt.genSaltSync(10);\r\nvar hash = bcrypt.hashSync(\"B4c0/\\/\", salt);\r\n// Store hash in your password DB.\r\n```\r\n\r\nTo check a password: \r\n\r\n```javascript\r\n// Load hash from your password DB.\r\nbcrypt.compareSync(\"B4c0/\\/\", hash); // true\r\nbcrypt.compareSync(\"not_bacon\", hash); // false\r\n```\r\n\r\nAuto-gen a salt and hash:\r\n\r\n```javascript\r\nvar hash = bcrypt.hashSync('bacon', 8);\r\n```\r\n\r\nUsage - Async\r\n-------------\r\nTo hash a password: \r\n\r\n```javascript\r\nvar bcrypt = require('bcryptjs');\r\nbcrypt.genSalt(10, function(err, salt) {\r\n bcrypt.hash(\"B4c0/\\/\", salt, function(err, hash) {\r\n // Store hash in your password DB.\r\n });\r\n});\r\n```\r\n\r\nTo check a password: \r\n\r\n```javascript\r\n// Load hash from your password DB.\r\nbcrypt.compare(\"B4c0/\\/\", hash, function(err, res) {\r\n // res == true\r\n});\r\nbcrypt.compare(\"not_bacon\", hash, function(err, res) {\r\n // res = false\r\n});\r\n```\r\n\r\nAuto-gen a salt and hash:\r\n\r\n```javascript\r\nbcrypt.hash('bacon', 8, function(err, hash) {\r\n});\r\n```\r\n\r\nAPI\r\n---\r\n\r\n - [bcrypt](#bcrypt)\r\n - [bcrypt.genSaltSync(rounds\\*, seed_length\\*)](#bcryptgensaltsyncrounds-seed_length)\r\n - [bcrypt.genSalt(rounds\\*, seed_length\\*, callback\\*)](#bcryptgensaltrounds-seed_length-callback)\r\n - [bcrypt.hashSync(s, salt\\*)](#bcrypthashsyncs-salt)\r\n - [bcrypt.hash(s, salt, callback)](#bcrypthashs-salt-callback)\r\n - [bcrypt.compareSync(s, hash)](#bcryptcomparesyncs-hash)\r\n - [bcrypt.compare(s, hash, callback)](#bcryptcompares-hash-callback)\r\n - [bcrypt.getRounds(hash)](#bcryptgetroundshash)\r\n - [bcrypt.getSalt(hash)](#bcryptgetsalthash)\r\n\r\n### bcrypt\r\nbcrypt namespace.\r\n\r\n\r\n### bcrypt.genSaltSync(rounds\\*, seed_length\\*)\r\nSynchronously generates a salt.\r\n\r\n| Name | Type | Description |\r\n| ---- | ---- | ----------- |\r\n| rounds\\* | number | Number of rounds to use, defaults to 10 if omitted |\r\n| seed_length\\* | number | Not supported. |\r\n| |||\r\n| **returns** | string | Resulting salt\r\n\r\n### bcrypt.genSalt(rounds\\*, seed_length\\*, callback\\*)\r\nAsynchronously generates a salt.\r\n\r\n| Name | Type | Description |\r\n| ---- | ---- | ----------- |\r\n| rounds\\* | (number ¦ function(Error, ?string)) | Number of rounds to use, defaults to 10 if omitted |\r\n| seed_length\\* | (number ¦ function(Error, ?string)) | Not supported. |\r\n| callback\\* | function(Error, ?string) | Callback receiving the error, if any, and the resulting salt |\r\n\r\n### bcrypt.hashSync(s, salt\\*)\r\nSynchronously generates a hash for the given string.\r\n\r\n| Name | Type | Description |\r\n| ---- | ---- | ----------- |\r\n| s | string | String to hash |\r\n| salt\\* | (number ¦ string) | Salt length to generate or salt to use, default to 10 |\r\n| |||\r\n| **returns** | ?string | Resulting hash, actually never null\r\n\r\n### bcrypt.hash(s, salt, callback)\r\nAsynchronously generates a hash for the given string.\r\n\r\n| Name | Type | Description |\r\n| ---- | ---- | ----------- |\r\n| s | string | String to hash |\r\n| salt | number ¦ string | Salt length to generate or salt to use |\r\n| callback | function(Error, ?string) | Callback receiving the error, if any, and the resulting hash |\r\n\r\n### bcrypt.compareSync(s, hash)\r\nSynchronously tests a string against a hash.\r\n\r\n| Name | Type | Description |\r\n| ---- | ---- | ----------- |\r\n| s | string | String to compare |\r\n| hash | string | Hash to test against |\r\n| |||\r\n| **returns** | boolean | true if matching, otherwise false\r\n| **throws** | Error | If an argument is illegal\r\n\r\n### bcrypt.compare(s, hash, callback)\r\nAsynchronously compares the given data against the given hash.\r\n\r\n| Name | Type | Description |\r\n| ---- | ---- | ----------- |\r\n| s | string | Data to compare |\r\n| hash | string | Data to be compared to |\r\n| callback | function(Error, boolean) | Callback receiving the error, if any, otherwise the result |\r\n| |||\r\n| **throws** | Error | If the callback argument is invalid\r\n\r\n### bcrypt.getRounds(hash)\r\nGets the number of rounds used to encrypt the specified hash.\r\n\r\n| Name | Type | Description |\r\n| ---- | ---- | ----------- |\r\n| hash | string | Hash to extract the used number of rounds from |\r\n| |||\r\n| **returns** | number | Number of rounds used\r\n| **throws** | Error | If hash is not a string\r\n\r\n### bcrypt.getSalt(hash)\r\nGets the salt portion from a hash.\r\n\r\n| Name | Type | Description |\r\n| ---- | ---- | ----------- |\r\n| hash | string | Hash to extract the salt from |\r\n| |||\r\n| **returns** | string | Extracted salt part portion\r\n| **throws** | Error | If `hash` is not a string or otherwise invalid\r\n\r\nCommand line\r\n------------\r\n`Usage: bcrypt [salt]`\r\n\r\nIf the input has spaces inside, simply surround it with quotes.\r\n\r\nDownloads\r\n---------\r\n* [Distributions](https://github.com/dcodeIO/bcrypt.js/tree/master/dist)\r\n* [ZIP-Archive](https://github.com/dcodeIO/bcrypt.js/archive/master.zip)\r\n* [Tarball](https://github.com/dcodeIO/bcrypt.js/tarball/master)\r\n\r\nCredits\r\n-------\r\nBased on work started by Shane Girish at [bcrypt-nodejs](https://github.com/shaneGirish/bcrypt-nodejs) (MIT-licensed),\r\nwhich is itself based on [javascript-bcrypt](http://code.google.com/p/javascript-bcrypt/) (New BSD-licensed).\r\n\r\nLicense\r\n-------\r\nApache License, Version 2.0 if not stated otherwise\r\n"}