{"name":"bcryptjs","description":"Optimized bcrypt in plain JavaScript with zero dependencies. Compatible to 'bcrypt'.","version":"2.0.1","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","browser":"dist/bcrypt-isaac.js","dependencies":{},"devDependencies":{"testjs":"~1","closurecompiler":"~1","metascript":"~0.18","bcrypt":"latest","utfx":"~1"},"licenses":[{"type":"New-BSD, MIT","url":"https://raw.githubusercontent.com/dcodeIO/bcrypt.js/master/LICENSE"}],"scripts":{"test":"node node_modules/testjs/bin/testjs","build":"node scripts/build.js","compile":"ccjs dist/bcrypt.js --compilation_level=ADVANCED_OPTIMIZATIONS --externs=externs/minimal-env.js --output_wrapper=\"(function(){%output%})();\" > dist/bcrypt.min.js","compile-isaac":"ccjs dist/bcrypt-isaac.js --compilation_level=ADVANCED_OPTIMIZATIONS --externs=externs/minimal-env.js --output_wrapper=\"(function(){%output%})();\" > dist/bcrypt-isaac.min.js","make":"npm run-script build && npm run-script compile && npm run-script compile-isaac && npm test"},"homepage":"https://github.com/dcodeIO/bcrypt.js","_id":"bcryptjs@2.0.1","_shasum":"7ddd96ea778f93bf3691e9da5907896a9a2ef0d8","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"dcode","email":"dcode@dcode.io"},"maintainers":[{"name":"dcode","email":"dcode@dcode.io"}],"dist":{"shasum":"7ddd96ea778f93bf3691e9da5907896a9a2ef0d8","size":76155,"noattachment":false,"tarball":"https://registry.npmmirror.com/bcryptjs/-/bcryptjs-2.0.1.tgz","integrity":"sha512-vwnsYVT075eSF1X8xN16atjIl3xtCHBj1bohTAv2OyuXZUqMXF8pBoCoXu4UnodnUGwigFT568MB2/nbjz6NLQ=="},"directories":{},"publish_time":1405389906954,"_hasShrinkwrap":false,"_cnpm_publish_time":1405389906954,"_cnpmcore_publish_time":"2021-12-16T11:52:29.226Z","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 compatible (via [crypto](http://nodejs.org/api/crypto.html)), also available via [npm](https://npmjs.org/package/bcryptjs) \r\n* Browser compatible (via [WebCryptoAPI](http://www.w3.org/TR/WebCryptoAPI))\r\n* AMD compatible\r\n* Zero production dependencies\r\n* Small footprint\r\n* ISAAC PRNG as default fallback with bcrypt-isaac.js\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### setRandomFallback(random)\r\n\r\nSets the random number generator to use as a fallback if neither node's `crypto` module nor the Web Crypto API\r\nis available.\r\n\r\n| Parameter | Type | Description\r\n|-----------------|-----------------|---------------\r\n| random | *function(number):!Array.<number>* | Function taking the number of bytes to generate as its sole argument, returning the corresponding array of cryptographically secure random byte values. \r\n| **@see** | | http://nodejs.org/api/crypto.html \r\n| **@see** | | http://www.w3.org/TR/WebCryptoAPI/ \r\n\r\n### genSaltSync(rounds=, seed_length=)\r\n\r\nSynchronously generates a salt.\r\n\r\n| Parameter | 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| **@returns** | *string* | Resulting salt \r\n| **@throws** | *Error* | If a random fallback is required but not set \r\n\r\n### genSalt(rounds=, seed_length=, callback)\r\n\r\nAsynchronously generates a salt.\r\n\r\n| Parameter | 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### hashSync(s, salt=)\r\n\r\nSynchronously generates a hash for the given string.\r\n\r\n| Parameter | 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| **@returns** | *string* | Resulting hash \r\n\r\n### hash(s, salt, callback, progressCallback=)\r\n\r\nAsynchronously generates a hash for the given string.\r\n\r\n| Parameter | 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| progressCallback | *function(number)* | Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per `MAX_EXECUTION_TIME = 100` ms. \r\n\r\n### compareSync(s, hash)\r\n\r\nSynchronously tests a string against a hash.\r\n\r\n| Parameter | Type | Description\r\n|-----------------|-----------------|---------------\r\n| s | *string* | String to compare \r\n| hash | *string* | Hash to test against \r\n| **@returns** | *boolean* | true if matching, otherwise false \r\n| **@throws** | *Error* | If an argument is illegal \r\n\r\n### compare(s, hash, callback, progressCallback=)\r\n\r\nAsynchronously compares the given data against the given hash.\r\n\r\n| Parameter | 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| progressCallback | *function(number)* | Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per `MAX_EXECUTION_TIME = 100` ms. \r\n| **@throws** | *Error* | If the callback argument is invalid \r\n\r\n### getRounds(hash)\r\n\r\nGets the number of rounds used to encrypt the specified hash.\r\n\r\n| Parameter | Type | Description\r\n|-----------------|-----------------|---------------\r\n| hash | *string* | Hash to extract the used number of rounds from \r\n| **@returns** | *number* | Number of rounds used \r\n| **@throws** | *Error* | If hash is not a string \r\n\r\n### getSalt(hash)\r\n\r\nGets the salt portion from a hash. Does not validate the hash.\r\n\r\n| Parameter | Type | Description\r\n|-----------------|-----------------|---------------\r\n| hash | *string* | Hash to extract the salt from \r\n| **@returns** | *string* | Extracted salt part \r\n| **@throws** | *Error* | If `hash` is not a string or otherwise invalid \r\n\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"}