{"id":20804411,"url":"https://github.com/sequencemedia/pbkdf2","last_synced_at":"2026-01-04T17:40:53.358Z","repository":{"id":65552661,"uuid":"594176674","full_name":"sequencemedia/pbkdf2","owner":"sequencemedia","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-23T04:20:37.000Z","size":1770,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-05-23T05:29:43.215Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sequencemedia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-27T19:28:19.000Z","updated_at":"2024-05-23T05:29:55.786Z","dependencies_parsed_at":"2023-12-28T05:31:08.074Z","dependency_job_id":"74bf713c-51b5-402b-8d9a-99d460ac0401","html_url":"https://github.com/sequencemedia/pbkdf2","commit_stats":{"total_commits":112,"total_committers":1,"mean_commits":112.0,"dds":0.0,"last_synced_commit":"38b9d23035c41466eec7400db82cee5d95a2a7fa"},"previous_names":[],"tags_count":253,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sequencemedia%2Fpbkdf2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sequencemedia%2Fpbkdf2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sequencemedia%2Fpbkdf2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sequencemedia%2Fpbkdf2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sequencemedia","download_url":"https://codeload.github.com/sequencemedia/pbkdf2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244173527,"owners_count":20410298,"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":"2024-11-17T19:09:15.953Z","updated_at":"2026-01-04T17:40:53.324Z","avatar_url":"https://github.com/sequencemedia.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @sequencemedia/pbkdf2\n\n## Compare a given password to a `hash` and `salt`\n\nExposes the crypto `pbkdf2` utilities as `async` functions for Node and the shell\n\nES functions are exported from the package root alongside a TS definition\n\n## Password validation by `hash` and `salt` comparison\n\nA password can be compared with a `hash` and `salt` (and the number of `iterations` that were used to compute it) to determine whether it is valid\n\nThe ES functions expect the same argument types as the underlying Node utilities\n\n- The `hash` is a `Buffer`\n- The `salt` is a `Buffer`\n- `iterations` is a `Number`\n- `keylen` is a `Number`\n- `digest` is a `String`\n\nEtc.\n\n### `compare`\n\nThe password is expected as the first argument, while the others are fields on a params object\n\n```javascript\nconst isValid = await compare(password, {\n  hash,\n  salt,\n  iterations,\n  keylen,\n  digest\n})\n```\n\n### `hash`\n\nAs with `compare`, the password is expected as the first argument, while the others are fields on a params object (except for `hash` which can of course be omitted)\n\n```javascript\nconst value = await hash(password, {\n  hash,\n  iterations,\n  keylen,\n  digest\n})\n```\n\n### `salt`\n\nAn `async` wrapper around `crypto.randomBytes()` to _generate_ a salt of the salt size\n\n```javascript\nconst value = await salt(size)\n```\n\n## In the shell\n\nScripts are exposed to `npm` in the package and each script can of course be invoked from the command line directly in the shell\n\n```json\n{\n  \"compare\": \"node scripts/compare.mjs\",\n  \"hash\": \"node scripts/hash.mjs\",\n  \"salt\": \"node scripts/salt.mjs\"\n}\n```\n\nWhere required, both the `hash` and `salt` arguments are expected from the command line to be strings in _Base64_ format. Both `iterations` and `keylen` are coerced from strings to numbers\n\n```bash\nnpm run compare -- \\\n  --password \u003cPASSWORD\u003e \\\n  --hash \u003cHASH\u003e \\\n  --salt \u003cSALT\u003e \\\n  --keylen \u003cKEY LENGTH\u003e \\\n  --iterations \u003cITERATIONS\u003e \\\n  --digest \u003cDIGEST\u003e\n```\n\n```bash\nnode ./scripts/compare.mjs \\\n  --password \u003cPASSWORD\u003e \\\n  --hash \u003cHASH\u003e \\\n  --salt \u003cSALT\u003e \\\n  --keylen \u003cKEY LENGTH\u003e \\\n  --iterations \u003cITERATIONS\u003e \\\n  --digest \u003cDIGEST\u003e\n```\n\nEtc.\n\n- The `hash` is decoded from a _Base64_ `String` to a `Buffer`\n- The `salt` is decoded from a _Base64_ `String` to a `Buffer`\n\n## Tests\n\n```bash\nnpm test\n```\n\n```bash\n./compare.sh\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsequencemedia%2Fpbkdf2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsequencemedia%2Fpbkdf2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsequencemedia%2Fpbkdf2/lists"}