{"id":28555039,"url":"https://github.com/cryptocoinjs/scryptsy","last_synced_at":"2025-07-06T09:31:21.441Z","repository":{"id":14187214,"uuid":"16893608","full_name":"cryptocoinjs/scryptsy","owner":"cryptocoinjs","description":"Scrypt KDF is used for BIP38 (encryption of private keys) and proof of work for some crypto currencies.","archived":false,"fork":false,"pushed_at":"2021-10-12T21:31:31.000Z","size":86,"stargazers_count":47,"open_issues_count":6,"forks_count":20,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-06-10T05:34:33.772Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cryptocoinjs.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}},"created_at":"2014-02-16T20:36:50.000Z","updated_at":"2025-02-12T20:25:47.000Z","dependencies_parsed_at":"2022-08-28T16:01:35.502Z","dependency_job_id":null,"html_url":"https://github.com/cryptocoinjs/scryptsy","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/cryptocoinjs/scryptsy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fscryptsy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fscryptsy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fscryptsy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fscryptsy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cryptocoinjs","download_url":"https://codeload.github.com/cryptocoinjs/scryptsy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptocoinjs%2Fscryptsy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262234830,"owners_count":23279525,"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":[],"created_at":"2025-06-10T05:30:30.187Z","updated_at":"2025-07-06T09:31:21.434Z","avatar_url":"https://github.com/cryptocoinjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"scryptsy\n========\n\n[![build status](https://secure.travis-ci.org/cryptocoinjs/scryptsy.svg)](http://travis-ci.org/cryptocoinjs/scryptsy)\n[![Coverage Status](https://img.shields.io/coveralls/cryptocoinjs/scryptsy.svg)](https://coveralls.io/r/cryptocoinjs/scryptsy)\n[![Version](http://img.shields.io/npm/v/scryptsy.svg)](https://www.npmjs.org/package/scryptsy)\n\n`scryptsy` is a pure Javascript implementation of the [scrypt][wiki] key derivation function that is fully compatible with Node.js and the browser (via Browserify).\n\n\nWhy?\n----\n\n`Scrypt` is an integral part of many crypto currencies. It's a part of the [BIP38](https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki) standard for encrypting private Bitcoin keys. It also serves as the [proof-of-work system](http://en.wikipedia.org/wiki/Proof-of-work_system) for many crypto currencies, most notably: Litecoin and Dogecoin.\n\n\n\nInstallation\n------------\n\n    npm install --save scryptsy\n\n\n\nBrowserify Note\n------------\n\nWhen using a browserified bundle, be sure to add `setImmediate` as a shim.\n\n\n\nExample\n-------\n\n```js\nconst scrypt = require('scryptsy')\n\nasync function main () {\n  var key = \"pleaseletmein\"\n  var salt = \"SodiumChloride\"\n  var data1 = scrypt(key, salt, 16384, 8, 1, 64)\n  console.log(data1.toString('hex'))\n  // =\u003e 7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887\n\n  // async is actually slower, but it will free up the event loop occasionally\n  // which will allow for front end GUI elements to update and cause it to not\n  // freeze up.\n  // See benchmarks below\n  // Passing 300 below means every 300 iterations internally will call setImmediate once\n  var data2 = await scrypt.async(key, salt, 16384, 8, 1, 64, undefined, 300)\n  console.log(data2.toString('hex'))\n  // =\u003e 7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887\n}\nmain().catch(console.error)\n```\n\n\nBenchmarks\n-------\n\nInternal iterations are N * p, so changing r doesn't affect the number of calls to setImmediate.\nDecreasing pI decreases performance in exchange for more frequently freeing the event loop.\n(pI Default is 5000 loops per setImmediate call)\n\nNote: these benchmarks were done on node v10 on a CPU with good single thread performance.\nbrowsers show a much larger difference. Please tinker with the pI setting to balance between\nperformance and GUI responsiveness.\n\nIf `pI \u003e= N`, setImmediate will only be called `p * 2` times total (on the i = 0 of each for loop).\n\n```\n---------------------------\ntime    : type : (N,r,p,pI) (pI = promiseInterval)\n---------------------------\n2266 ms :  sync (2^16,16,1)\n2548 ms : async (2^16,16,1,5000)\n12.44% increase\n---------------------------\n2616 ms :  sync (2^16,1,16)\n2995 ms : async (2^16,1,16,5000)\n14.49% increase\n---------------------------\n2685 ms :  sync (2^20,1,1)\n3090 ms : async (2^20,1,1,5000)\n15.08% increase\n---------------------------\n2235 ms :  sync (2^16,16,1)\n2627 ms : async (2^16,16,1,10)\n17.54% increase\n---------------------------\n2592 ms :  sync (2^16,1,16)\n3305 ms : async (2^16,1,16,10)\n27.51% increase\n---------------------------\n2705 ms :  sync (2^20,1,1)\n3363 ms : async (2^20,1,1,10)\n24.33% increase\n---------------------------\n2278 ms :  sync (2^16,16,1)\n2773 ms : async (2^16,16,1,1)\n21.73% increase\n---------------------------\n2617 ms :  sync (2^16,1,16)\n5632 ms : async (2^16,1,16,1)\n115.21% increase\n---------------------------\n2727 ms :  sync (2^20,1,1)\n5723 ms : async (2^20,1,1,1)\n109.86% increase\n---------------------------\n```\n\nAPI\n---\n\n### scrypt(key, salt, N, r, p, keyLenBytes, [progressCallback])\n\n- **key**: The key. Either `Buffer` or `string`.\n- **salt**: The salt. Either `Buffer` or `string`.\n- **N**: The number of iterations. `number` (integer)\n- **r**: Memory factor. `number` (integer)\n- **p**: Parallelization factor. `number` (integer)\n- **keyLenBytes**: The number of bytes to return. `number` (integer)\n- **progressCallback**: Call callback on every `1000` ops. Passes in `{current, total, percent}` as first parameter to `progressCallback()`.\n\nReturns `Buffer`.\n\n### scrypt.async(key, salt, N, r, p, keyLenBytes, [progressCallback, promiseInterval])\n\n- **key**: The key. Either `Buffer` or `string`.\n- **salt**: The salt. Either `Buffer` or `string`.\n- **N**: The number of iterations. `number` (integer)\n- **r**: Memory factor. `number` (integer)\n- **p**: Parallelization factor. `number` (integer)\n- **keyLenBytes**: The number of bytes to return. `number` (integer)\n- **progressCallback**: Call callback on every `1000` ops. Passes in `{current, total, percent}` as first parameter to `progressCallback()`.\n- **promiseInterval**: The number of internal iterations before calling setImmediate once to free the event loop.\n\nReturns `Promise\u003cBuffer\u003e`.\n\n\n\nResources\n---------\n- [Tarsnap Blurb on Scrypt][tarsnap]\n- [Scrypt Whitepaper](http://www.tarsnap.com/scrypt/scrypt.pdf)\n- [IETF Scrypt](https://tools.ietf.org/html/draft-josefsson-scrypt-kdf-00) (Test vector params are [incorrect](https://twitter.com/dchest/status/247734446881640448).)\n\n\nLicense\n-------\n\nMIT\n\n\n[wiki]: http://en.wikipedia.org/wiki/Scrypt\n[tarsnap]: http://www.tarsnap.com/scrypt.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptocoinjs%2Fscryptsy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptocoinjs%2Fscryptsy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptocoinjs%2Fscryptsy/lists"}