{"name":"bcryptjs","description":"Optimized bcrypt in plain JavaScript with zero dependencies. Compatible to 'bcrypt'.","version":"2.4.2","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":"git+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.js","dependencies":{},"devDependencies":{"testjs":"~1","closurecompiler":"~1","metascript":"~0.18","bcrypt":"latest","utfx":"~1"},"license":"MIT","scripts":{"test":"node node_modules/testjs/bin/testjs","build":"node scripts/build.js","compile":"node node_modules/closurecompiler/bin/ccjs dist/bcrypt.js --compilation_level=SIMPLE_OPTIMIZATIONS --create_source_map=dist/bcrypt.min.map > dist/bcrypt.min.js","compress":"gzip -c -9 dist/bcrypt.min.js > dist/bcrypt.min.js.gz","make":"npm run-script build && npm run-script compile && npm test"},"gitHead":"2fa2b7cadf8a5e2bbe8436439b219b0d5596dbe7","homepage":"https://github.com/dcodeIO/bcrypt.js#readme","_id":"bcryptjs@2.4.2","_shasum":"6faee62ed9cb636fbbb3f4b5a4164bbed5a9ef7e","_from":".","_npmVersion":"4.0.5","_nodeVersion":"6.9.1","_npmUser":{"name":"dcode","email":"dcode+npm@dcode.io"},"dist":{"shasum":"6faee62ed9cb636fbbb3f4b5a4164bbed5a9ef7e","tarball":"http://registry-npm.ywwl.com/bcryptjs/download/bcryptjs-2.4.2.tgz","integrity":"sha512-4m7EJZjGs+W+1aIdc0zzdUqN7vV22PRSN1JN2hMQRdym3ula76QGCofg5iAPpdVRxJfSXlYAEDrVzOpS7kUh+A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC6RTa1psD3eLxF4OaGUXvvsoMul92pJcUrrtcyw1pobAIgBPDfyQZaIiFG94fEbNLviCAvqB1K72CS+oEDd/jXVGY="}],"size":78160,"noattachment":false,"key":"/bcryptjs/-/bcryptjs-2.4.2.tgz"},"maintainers":[{"name":"dcode","email":"dcode@dcode.io"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/bcryptjs-2.4.2.tgz_1486454599210_0.048139352118596435"},"directories":{},"readme":"bcrypt.js\r\n=========\r\nOptimized bcrypt in JavaScript with zero dependencies. Compatible to the C++ [bcrypt](https://npmjs.org/package/bcrypt)\r\nbinding on node.js and also working in the browser.\r\n\r\n<a href=\"https://travis-ci.org/dcodeIO/bcrypt.js\"><img alt=\"build static\" src=\"https://travis-ci.org/dcodeIO/bcrypt.js.svg?branch=master\" /></a> <a href=\"https://npmjs.org/package/bcryptjs\"><img src=\"https://img.shields.io/npm/v/bcryptjs.svg\" alt=\"\"></a> <a href=\"https://npmjs.org/package/bcryptjs\"><img src=\"https://img.shields.io/npm/dm/bcryptjs.svg\" alt=\"\"></a> <a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=dcode%40dcode.io&item_name=Open%20Source%20Software%20Donation&item_number=dcodeIO%2Fbcrypt.js\"><img alt=\"donate ❤\" src=\"https://img.shields.io/badge/donate-❤-ff2244.svg\"></a>\r\n\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 ([about 30%](https://github.com/dcodeIO/bcrypt.js/wiki/Benchmark)), effectively reducing the number of iterations that can be\r\nprocessed in an equal time span.\r\n\r\nThe maximum input length is 72 bytes (note that UTF8 encoded characters use up to 4 bytes) and the length of generated\r\nhashes is 60 characters.\r\n\r\nUsage\r\n-----\r\nThe library is compatible with CommonJS and AMD loaders and is exposed globally as `dcodeIO.bcrypt` if neither is\r\navailable.\r\n\r\n### node.js\r\n\r\nOn node.js, the inbuilt [crypto module](http://nodejs.org/api/crypto.html)'s randomBytes interface is used to obtain\r\nsecure random numbers.\r\n\r\n`npm install bcryptjs`\r\n\r\n```js\r\nvar bcrypt = require('bcryptjs');\r\n...\r\n```\r\n\r\n### Browser\r\n\r\nIn the browser, bcrypt.js relies on [Web Crypto API](http://www.w3.org/TR/WebCryptoAPI)'s getRandomValues\r\ninterface to obtain secure random numbers. If no cryptographically secure source of randomness is available, you may\r\nspecify one through [bcrypt.setRandomFallback](https://github.com/dcodeIO/bcrypt.js#setrandomfallbackrandom).\r\n\r\n```js\r\nvar bcrypt = dcodeIO.bcrypt;\r\n...\r\n```\r\n\r\nor\r\n\r\n```js\r\nrequire.config({\r\n    paths: { \"bcrypt\": \"/path/to/bcrypt.js\" }\r\n});\r\nrequire([\"bcrypt\"], function(bcrypt) {\r\n    ...\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// As of bcryptjs 2.4.0, compare returns a promise if callback is omitted:\r\nbcrypt.compare(\"B4c0/\\/\", hash).then((res) => {\r\n    // res === true\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\n**Note:** Under the hood, asynchronisation splits a crypto operation into small chunks. After the completion of a chunk, the execution of the next chunk is placed on the back of [JS event loop queue](https://developer.mozilla.org/en/docs/Web/JavaScript/EventLoop), thus efficiently sharing the computational resources with the other operations in the queue.\r\n\r\nAPI\r\n---\r\n### setRandomFallback(random)\r\n\r\nSets the pseudo random number generator to use as a fallback if neither node's `crypto` module nor the Web Crypto\r\nAPI is available. Please note: It is highly important that the PRNG used is cryptographically secure and that it is\r\nseeded properly!\r\n\r\n| Parameter       | Type            | Description\r\n|-----------------|-----------------|---------------\r\n| random          | *function(number):!Array.&lt;number&gt;* | 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**Hint:** You might use [isaac.js](https://github.com/rubycon/isaac.js) as a CSPRNG but you still have to make sure to\r\nseed it properly.\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 &#124; function(Error, string=)* | Number of rounds to use, defaults to 10 if omitted \r\n| seed_length     | *number &#124; function(Error, string=)* | Not supported. \r\n| callback        | *function(Error, string=)* | Callback receiving the error, if any, and the resulting salt \r\n| **@returns**    | *Promise*       | If `callback` has been omitted\r\n| **@throws**     | *Error*         | If `callback` is present but not a function\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 &#124; 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 &#124; 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| **@returns**    | *Promise*       | If `callback` has been omitted\r\n| **@throws**     | *Error*         | If `callback` is present but not a function\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| **@returns**    | *Promise*       | If `callback` has been omitted \r\n| **@throws**     | *Error*         | If `callback` is present but not a function\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 <input> [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\nNew-BSD / MIT ([see](https://github.com/dcodeIO/bcrypt.js/blob/master/LICENSE))\r\n","publish_time":1486454601341,"_cnpm_publish_time":1486454601341,"dist-tags":{"latest":"3.0.3"}}