{"id":17498368,"url":"https://github.com/simonepri/phc-format","last_synced_at":"2025-04-14T21:51:51.878Z","repository":{"id":48570083,"uuid":"124311066","full_name":"simonepri/phc-format","owner":"simonepri","description":"📝 PHC String Format implementation for Node.JS","archived":false,"fork":false,"pushed_at":"2021-07-20T04:14:49.000Z","size":40,"stargazers_count":18,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T15:08:09.951Z","etag":null,"topics":["competition","crypt","crypto","decode","deserialize","deserializer","encode","format","hashing","mcf","nodejs","parser","password","phc","serialize","serializer","standard","string"],"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/simonepri.png","metadata":{"files":{"readme":"readme.md","changelog":null,"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":"2018-03-08T00:07:40.000Z","updated_at":"2024-12-03T12:54:01.000Z","dependencies_parsed_at":"2022-09-26T20:01:01.511Z","dependency_job_id":null,"html_url":"https://github.com/simonepri/phc-format","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Fphc-format","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Fphc-format/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Fphc-format/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Fphc-format/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonepri","download_url":"https://codeload.github.com/simonepri/phc-format/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968741,"owners_count":21191158,"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":["competition","crypt","crypto","decode","deserialize","deserializer","encode","format","hashing","mcf","nodejs","parser","password","phc","serialize","serializer","standard","string"],"created_at":"2024-10-19T16:50:24.774Z","updated_at":"2025-04-14T21:51:51.850Z","avatar_url":"https://github.com/simonepri.png","language":"JavaScript","readme":"\u003ch1 align=\"center\"\u003e\n  \u003cb\u003ephc-format\u003c/b\u003e\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003c!-- Version - npm --\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@phc/format\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/@phc/format.svg\" alt=\"Latest version on npm\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Downloads - npm --\u003e\n  \u003ca href=\"https://npm-stat.com/charts.html?package=@phc/format\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dt/@phc/format.svg\" alt=\"Downloads on npm\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- License - MIT --\u003e\n  \u003ca href=\"https://github.com/simonepri/phc-format/tree/master/license\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/simonepri/phc-format.svg\" alt=\"Project license\" /\u003e\n  \u003c/a\u003e\n\n  \u003cbr/\u003e\n\n  \u003c!-- Lint --\u003e\n  \u003ca href=\"https://github.com/simonepri/phc-format/actions?query=workflow:lint+branch:master\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/phc-format/workflows/lint/badge.svg?branch=master\" alt=\"Lint status\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test - macOS --\u003e\n  \u003ca href=\"https://github.com/simonepri/phc-format/actions?query=workflow:test-macos+branch:master\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/phc-format/workflows/test-macos/badge.svg?branch=master\" alt=\"Test macOS status\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test - Ubuntu --\u003e\n  \u003ca href=\"https://github.com/simonepri/phc-format/actions?query=workflow:test-ubuntu+branch:master\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/phc-format/workflows/test-ubuntu/badge.svg?branch=master\" alt=\"Test Ubuntu status\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test - Windows --\u003e\n  \u003ca href=\"https://github.com/simonepri/phc-format/actions?query=workflow:test-windows+branch:master\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/phc-format/workflows/test-windows/badge.svg?branch=master\" alt=\"Test Windows status\" /\u003e\n  \u003c/a\u003e\n\n  \u003cbr/\u003e\n\n  \u003c!-- Coverage - Codecov --\u003e\n  \u003ca href=\"https://codecov.io/gh/simonepri/phc-format\"\u003e\n    \u003cimg src=\"https://img.shields.io/codecov/c/github/simonepri/phc-format/master.svg\" alt=\"Codecov Coverage report\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- DM - Snyk --\u003e\n  \u003ca href=\"https://snyk.io/test/github/simonepri/phc-format?targetFile=package.json\"\u003e\n    \u003cimg src=\"https://snyk.io/test/github/simonepri/phc-format/badge.svg?targetFile=package.json\" alt=\"Known Vulnerabilities\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- DM - David --\u003e\n  \u003ca href=\"https://david-dm.org/simonepri/phc-format\"\u003e\n    \u003cimg src=\"https://david-dm.org/simonepri/phc-format/status.svg\" alt=\"Dependency Status\" /\u003e\n  \u003c/a\u003e\n\n  \u003cbr/\u003e\n\n  \u003c!-- Code Style - XO-Prettier --\u003e\n  \u003ca href=\"https://github.com/xojs/xo\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/code_style-XO+Prettier-5ed9c7.svg\" alt=\"XO Code Style used\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test Runner - AVA --\u003e\n  \u003ca href=\"https://github.com/avajs/ava\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/test_runner-AVA-fb3170.svg\" alt=\"AVA Test Runner used\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test Coverage - Istanbul --\u003e\n  \u003ca href=\"https://github.com/istanbuljs/nyc\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/test_coverage-NYC-fec606.svg\" alt=\"Istanbul Test Coverage used\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Init - ni --\u003e\n  \u003ca href=\"https://github.com/simonepri/ni\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/initialized_with-ni-e74c3c.svg\" alt=\"NI Scaffolding System used\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Release - np --\u003e\n  \u003ca href=\"https://github.com/sindresorhus/np\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/released_with-np-6c8784.svg\" alt=\"NP Release System used\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  📝 PHC string format serializer/deserializer\n\n  \u003cbr/\u003e\n\n  \u003csub\u003e\n    Coded with ❤️ by \u003ca href=\"#authors\"\u003eSimone Primarosa\u003c/a\u003e.\n  \u003c/sub\u003e\n\u003c/p\u003e\n\n## Motivation\nThe [PHC String Format][specs:phc] is an attempt to specify a common hash string format that's a restricted \u0026 well defined subset of the Modular Crypt Format. New hashes are strongly encouraged to adhere to the PHC specification, rather than the much looser [Modular Crypt Format][specs:mcf].\n\n## Install\n\n```bash\nnpm install --save @phc/format\n```\n\n## Usage\n\n```js\nconst phc = require('@phc/format');\n\nconst phcobj = {\n  id: 'pbkdf2-sha256',\n  params: {i: 6400},\n  salt: Buffer.from('0ZrzXitFSGltTQnBWOsdAw', 'base64'),\n  hash: Buffer.from('Y11AchqV4b0sUisdZd0Xr97KWoymNE0LNNrnEgY4H9M', 'base64'),\n};\n\nconst phcstr = \"$pbkdf2-sha256$i=6400$0ZrzXitFSGltTQnBWOsdAw$Y11AchqV4b0sUisdZd0Xr97KWoymNE0LNNrnEgY4H9M\";\n\nphc.serialize(phcobj);\n// =\u003e phcstr\n\nphc.deserialize(phcstr);\n// =\u003e phcobj\n```\n\nYou can also pass an optional version parameter.\n\n```js\nconst phc = require('@phc/format');\n\nconst phcobj = {\n  id: 'argon2i',\n  version: 19,\n  params: {\n    m: 120,\n    t: 5000,\n    p: 2\n  },\n  salt: Buffer.from('iHSDPHzUhPzK7rCcJgOFfg', 'base64'),\n  hash: Buffer.from('J4moa2MM0/6uf3HbY2Tf5Fux8JIBTwIhmhxGRbsY14qhTltQt+Vw3b7tcJNEbk8ium8AQfZeD4tabCnNqfkD1g', 'base64'),\n};\n\nconst phcstr = \"$argon2i$v=19$m=120,t=5000,p=2$iHSDPHzUhPzK7rCcJgOFfg$J4moa2MM0/6uf3HbY2Tf5Fux8JIBTwIhmhxGRbsY14qhTltQt+Vw3b7tcJNEbk8ium8AQfZeD4tabCnNqfkD1g\";\n\nphc.serialize(phcobj);\n// =\u003e phcstr\n\nphc.deserialize(phcstr);\n// =\u003e phcobj\n```\n\n## API\n\n#### TOC\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#serialize\"\u003eserialize(opts)\u003c/a\u003e ⇒ \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eGenerates a PHC string using the data provided.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#deserialize\"\u003edeserialize(phcstr)\u003c/a\u003e ⇒ \u003ccode\u003eObject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eParses data from a PHC string.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ca name=\"serialize\"\u003e\u003c/a\u003e\n\n### serialize(opts) ⇒ \u003ccode\u003estring\u003c/code\u003e\nGenerates a PHC string using the data provided.\n\n**Kind**: global function  \n**Returns**: \u003ccode\u003estring\u003c/code\u003e - The hash string adhering to the PHC format.  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| opts | \u003ccode\u003eObject\u003c/code\u003e | Object that holds the data needed to generate the PHC string. |\n| opts.id | \u003ccode\u003estring\u003c/code\u003e | Symbolic name for the function. |\n| [opts.version] | \u003ccode\u003eNumber\u003c/code\u003e | The version of the function. |\n| [opts.params] | \u003ccode\u003eObject\u003c/code\u003e | Parameters of the function. |\n| [opts.salt] | \u003ccode\u003eBuffer\u003c/code\u003e | The salt as a binary buffer. |\n| [opts.hash] | \u003ccode\u003eBuffer\u003c/code\u003e | The hash as a binary buffer. |\n\n\u003ca name=\"deserialize\"\u003e\u003c/a\u003e\n\n### deserialize(phcstr) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nParses data from a PHC string.\n\n**Kind**: global function  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - The object containing the data parsed from the PHC string.  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| phcstr | \u003ccode\u003estring\u003c/code\u003e | A PHC string to parse. |\n\n## Contributing\nContributions are REALLY welcome and if you find a security flaw in this code, PLEASE [report it][new issue].  \nPlease check the [contributing guidelines][contributing] for more details. Thanks!\n\n## Authors\n- **Simone Primarosa** - *Github* ([@simonepri][github:simonepri]) • *Twitter* ([@simoneprimarosa][twitter:simoneprimarosa])\n\nSee also the list of [contributors][contributors] who participated in this project.\n\n## License\nThis project is licensed under the MIT License - see the [license][license] file for details.\n\n\n\u003c!-- Links --\u003e\n[start]: https://github.com/simonepri/phc-format#start-of-content\n[new issue]: https://github.com/simonepri/phc-format/issues/new\n[contributors]: https://github.com/simonepri/phc-format/contributors\n\n[license]: https://github.com/simonepri/phc-format/tree/master/license\n[contributing]: https://github.com/simonepri/phc-format/tree/master/.github/contributing.md\n\n[github:simonepri]: https://github.com/simonepri\n[twitter:simoneprimarosa]: http://twitter.com/intent/user?screen_name=simoneprimarosa\n\n[specs:mcf]: https://github.com/ademarre/binary-mcf\n[specs:phc]: https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonepri%2Fphc-format","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonepri%2Fphc-format","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonepri%2Fphc-format/lists"}