{"id":29061721,"url":"https://github.com/heliomarpm/cryptoh","last_synced_at":"2025-07-28T23:09:34.867Z","repository":{"id":299787206,"uuid":"994373076","full_name":"heliomarpm/cryptoh","owner":"heliomarpm","description":"A clean and easy-to-use cryptography utility library for Node.js, built on top of the native crypto module.","archived":false,"fork":false,"pushed_at":"2025-07-07T13:46:33.000Z","size":1068,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2025-07-18T12:55:08.544Z","etag":null,"topics":["crypto","crypto-helper","cryptography","cryptography-algorithms","cryptography-library","cryptoh","helpers","helpers-library","md5","node-library","security","sha1","sha256","sha512","utils-library"],"latest_commit_sha":null,"homepage":"https://heliomarpm.github.io/cryptoh","language":"TypeScript","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/heliomarpm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"docs/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","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,"zenodo":null},"funding":{"github":"heliomarpm","ko_fi":"heliomarpm","liberapay":"heliomarpm","custom":["https://www.paypal.com/donate?business=KBVHLR7Z9V7B2\u0026no_recurring=0\u0026currency_code=USD","https://www.paypal.com/donate?business=KBVHLR7Z9V7B2\u0026no_recurring=0\u0026currency_code=BRL"]}},"created_at":"2025-06-01T19:52:28.000Z","updated_at":"2025-07-07T13:46:36.000Z","dependencies_parsed_at":"2025-06-27T08:05:03.440Z","dependency_job_id":"8a61d71e-8bc9-4546-b323-d50bda04c3de","html_url":"https://github.com/heliomarpm/cryptoh","commit_stats":null,"previous_names":["heliomarpm/cryptoh"],"tags_count":2,"template":false,"template_full_name":"heliomarpm/tslib-template","purl":"pkg:github/heliomarpm/cryptoh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heliomarpm%2Fcryptoh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heliomarpm%2Fcryptoh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heliomarpm%2Fcryptoh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heliomarpm%2Fcryptoh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heliomarpm","download_url":"https://codeload.github.com/heliomarpm/cryptoh/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heliomarpm%2Fcryptoh/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267600438,"owners_count":24113782,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["crypto","crypto-helper","cryptography","cryptography-algorithms","cryptography-library","cryptoh","helpers","helpers-library","md5","node-library","security","sha1","sha256","sha512","utils-library"],"created_at":"2025-06-27T08:04:43.531Z","updated_at":"2025-07-28T23:09:34.862Z","avatar_url":"https://github.com/heliomarpm.png","language":"TypeScript","funding_links":["https://github.com/sponsors/heliomarpm","https://ko-fi.com/heliomarpm","https://liberapay.com/heliomarpm","https://www.paypal.com/donate?business=KBVHLR7Z9V7B2\u0026no_recurring=0\u0026currency_code=USD","https://www.paypal.com/donate?business=KBVHLR7Z9V7B2\u0026no_recurring=0\u0026currency_code=BRL"],"categories":[],"sub_categories":[],"readme":"\u003cdiv id=\"top\" align=\"center\"\u003e\n\u003ch1\u003e\n\n  \u003cimg src=\"./logo.png\" alt=\"Crypto Helper\" width=\"128\" /\u003e\n  \u003cbr\u003e Cryptography Helper \u003ca href=\"https://navto.me/heliomarpm\" target=\"_blank\"\u003e\u003cimg src=\"https://navto.me/assets/navigatetome-brand.png\" width=\"32\"/\u003e\u003c/a\u003e\n\n  [![DeepScan grade][url-deepscan-badge]][url-deepscan]\n  [![CodeFactor][url-codefactor-badge]][url-codefactor]\n  [![Test][url-test-badge]][url-test]\n  [![Coverage][url-coverage-badge]][url-coverage-report]\n\n  [![NPM version][url-npm-badge]][url-npm]\n  [![Downloads][url-downloads-badge]][url-downloads]\n\n  \u003c!-- ![Node.js](https://img.shields.io/badge/node.js-%2343853D.svg?style=for-the-badge\u0026logo=node.js\u0026logoColor=white)\n  ![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge\u0026logo=typescript\u0026logoColor=white)\n  ![Biome](https://img.shields.io/badge/biomejs-%23404d59.svg?style=for-the-badge\u0026logo=biome\u0026logoColor=white)\n  ![Semantic Release](https://img.shields.io/badge/semantic_release-%23000000.svg?style=for-the-badge\u0026logo=semantic-release\u0026logoColor=white)\n  [![License](https://img.shields.io/github/license/heliomarpm/cryptoh?style=for-the-badge)](./LICENSE) --\u003e\n\n\u003c/h1\u003e\n\n\u003cdiv class=\"badges\"\u003e\n\n  [![PayPal][url-paypal-badge]][url-paypal]\n  [![Ko-fi][url-kofi-badge]][url-kofi]\n  [![Liberapay][url-liberapay-badge]][url-liberapay]\n  [![GitHub Sponsors][url-github-sponsors-badge]][url-github-sponsors]\n  \n\u003c/div\u003e\n\u003c/div\u003e\n\n## 📚 Summary\n\nA clean and easy-to-use cryptography utility library for Node.js built on top of the native crypto module. It provides modern hashing, secure random generation, RSA key pair management, and digital signature utilities with a clean API.\n\n### Requirements\n\n- Node.js v16+\n\n\n## 🚀 Features\n- 📌 Hash text values using SHA-1, SHA-256, SHA-512, and MD5\n- 🔒 Compare hashed values securely using timingSafeEqual\n- 🔑 Generate secure RSA 2048-bit key pairs\n- ✍️ Create and verify digital signatures\n- 🎲 Generate cryptographically secure random salts\n- 📝 Fully typed with TypeScript\n\n\n## 🔧 Usage\n\n**Install the library:**\n\n```bash\nnpm install @heliomarpm/cryptoh\n```\n\n### ✏️ Example Code\n\n```typescript\nimport cryptoh, { HashAlgorithm } from \"cryptoh\";\n\nasync function main() {\n  // 👤 User registration (secure password storage)\n  const password = \"My$ecureP@ssword123\";\n\n  // Generate a unique salt for the user\n  const salt = await cryptoh.random.generateSalt(16);\n\n  // Concatenate password + salt and generate the hash\n  const hashedPassword = await cryptoh.hash.generate(password + salt, HashAlgorithm.SHA512);\n\n  console.log(\"Salt:\", salt);\n  console.log(\"Hashed password:\", hashedPassword);\n\n  // You would typically save this salt and hashedPassword to your database\n  const storedCredentials = { salt, hashedPassword };\n\n  // 👤 User login (password verification)\n  const passwordAttempt = \"My$ecureP@ssword123\";\n\n  // Recreate the hash with the stored salt and compare it to the stored hash\n  const isPasswordValid = await cryptoh.hash.verify(\n    passwordAttempt + storedCredentials.salt,\n    storedCredentials.hashedPassword,\n    HashAlgorithm.SHA512\n  );\n\n  console.log(\"Is password valid?\", isPasswordValid); // true if matches\n\n  // 🔐 Digital signature for sensitive payload (e.g., tokens, receipts, or important data)\n  const payload = JSON.stringify({\n    userId: 789,\n    email: \"user@example.com\",\n    timestamp: Date.now()\n  });\n\n  // Generate an RSA key pair\n  const { publicKey, privateKey } = await cryptoh.keyPair.generate();\n\n  // Sign the payload with the private key\n  const signature = await cryptoh.sign.generate(payload, privateKey);\n\n  console.log(\"Signature (base64):\", Buffer.from(signature, \"hex\").toString(\"base64\"));\n\n  // Verify the signature using the public key\n  const isSignatureValid = await cryptoh.sign.verify(payload, signature, publicKey);\n\n  console.log(\"Is signature valid?\", isSignatureValid); // true if signature matches\n}\n\nmain();\n```\n\n## 📚 API Reference\n\nSee the [API documentation](https://heliomarpm.github.io/cryptoh) for a complete list of available functions and their signatures.\n\n### 🔒 cryptoh.hash\n\n- Hashes the given text using the specified algorithm (default: SHA-256). \\\n`generate(text: string, algorithm?: HashAlgorithm): Promise\u003cstring\u003e`\n\n- Securely compares a plain text value with a given hash. \\\n`verify(text: string, hash: string, algorithm?: HashAlgorithm): Promise\u003cboolean\u003e`\n\n### 🎲 cryptoh.random\n\n- Generates a cryptographically secure random salt as a hex string. Default length: 16 bytes. \\\n`generateSalt(length?: number): Promise\u003cstring\u003e`\n\n### 🔑 cryptoh.keyPair\n\n- Generates a 2048-bit RSA key pair with PEM encoding. \\\n`generate(): Promise\u003c{ publicKey: string, privateKey: string }\u003e`\n\n### ✍️ cryptoh.sign\n\n- Generates a digital signature for the provided data using the private key. \\\n`generate(data: string, privateKey: string, algorithm?: HashAlgorithm): Promise\u003cstring\u003e`\n\n- Verifies the authenticity of a digital signature. \\\n`verify(data: string, signature: string, publicKey: string, algorithm?: HashAlgorithm): Promise\u003cboolean\u003e`\n\n\n## 📦 Project Scripts\n\n* `npm run check` — runs formatter, linter and import sorting to the requested files\n* `npm run format` — run the formatter on a set of files\n* `npm run lint` — run various checks on a set of files\n* `npm run test` — run unit tests\n* `npm run test:c` — run unit tests with coverage\n* `npm run docs:dev` — run documentation locally\n* `npm run commit` - run conventional commits check\n* `npm run release:test` — dry run semantic release \n* `npm run build` — build library\n\n\n## 📦 Dependencies\n\n✅ Zero runtime dependencies — relies solely on Node.js native crypto module. \\\n🔄 All devDependencies are pinned to latest stable versions\n\n\n## 🤝 Contributing\n\nWe welcome contributions! Please read:\n\n- [Code of Conduct](docs/CODE_OF_CONDUCT.md)\n- [Contributing Guide](docs/CONTRIBUTING.md)\n\nThank you to everyone who has already contributed to the project!\n\n\u003ca href=\"https://github.com/heliomarpm/cryptoh/graphs/contributors\" target=\"_blank\"\u003e\n  \u003c!-- \u003cimg src=\"https://contrib.rocks/image?repo=heliomarpm/cryptoh\" /\u003e --\u003e\n  \u003cimg src=\"https://contrib.nn.ci/api?repo=heliomarpm/cryptoh\u0026no_bot=true\" /\u003e\n\u003c/a\u003e\n\n\u003c!-- ###### Made with [contrib.rocks](https://contrib.rocks). --\u003e\n###### Made with [contrib.nn](https://contrib.nn.ci).\n\n### ❤️ Support this project\n\nIf this project helped you in any way, there are several ways to contribute. \\\nHelp us maintain and improve this template:\n\n⭐ Starring the repository \\\n🐞 Reporting bugs \\\n💡 Suggest features \\\n🧾 Improving the documentation \\\n📢 Share with others\n\n💵 Supporting via GitHub Sponsors, Ko-fi, Paypal or Liberapay, you decide. 😉\n\n\u003cdiv class=\"badges\"\u003e\n\n  [![PayPal][url-paypal-badge]][url-paypal]\n  [![Ko-fi][url-kofi-badge]][url-kofi]\n  [![Liberapay][url-liberapay-badge]][url-liberapay]\n  [![GitHub Sponsors][url-github-sponsors-badge]][url-github-sponsors]\n\n\u003c/div\u003e\n\n\n## 📝 License\n\n[MIT © Heliomar P. Marques](LICENSE)  \u003ca href=\"#top\"\u003e🔝\u003c/a\u003e\n\n----\n\u003c!-- Sponsor badges --\u003e\n[url-paypal-badge]: https://img.shields.io/badge/donate%20on-paypal-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=0475fe\n[url-paypal]: https://bit.ly/paypal-sponsor-heliomarpm\n[url-kofi-badge]: https://img.shields.io/badge/kofi-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=ff5f5f\n[url-kofi]: https://ko-fi.com/heliomarpm\n[url-liberapay-badge]: https://img.shields.io/badge/liberapay-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=f6c915\n[url-liberapay]: https://liberapay.com/heliomarpm\n[url-github-sponsors-badge]: https://img.shields.io/badge/GitHub%20-Sponsor-1C1E26?style=for-the-badge\u0026labelColor=1C1E26\u0026color=db61a2\n[url-github-sponsors]: https://github.com/sponsors/heliomarpm\n\n\u003c!-- GitHub Actions badges --\u003e\n[url-codeql-badge]: https://github.com/heliomarpm/cryptoh/actions/workflows/codeql.yml/badge.svg \n[url-codeql]: https://github.com/heliomarpm/cryptoh/security/code-scanning\n[url-test-badge]: https://github.com/heliomarpm/cryptoh/actions/workflows/0.test.yml/badge.svg\n[url-test]: https://github.com/heliomarpm/cryptoh/actions/workflows/0.test.yml\n[url-coverage-badge2]: https://img.shields.io/badge/coverage-dynamic.svg?label=coverage\u0026color=informational\u0026style=flat\u0026logo=jest\u0026query=$.coverage\u0026url=https://heliomarpm.github.io/cryptoh/coverage-badge.json\n[url-coverage-badge]: https://img.shields.io/endpoint?url=https://heliomarpm.github.io/cryptoh/coverage/coverage-badge.json\n[url-coverage-report]: https://heliomarpm.github.io/cryptoh/coverage\n\n\u003c!-- https://img.shields.io/endpoint?url=https://heliomarpm.github.io/cryptoh/coverage-badge.json\u0026label=coverage\u0026suffix=%25 --\u003e\n[url-release-badge]: https://github.com/heliomarpm/cryptoh/actions/workflows/3.release.yml/badge.svg\n[url-release]: https://github.com/heliomarpm/cryptoh/actions/workflows/3.release.yml\n[url-publish-badge]: https://github.com/heliomarpm/cryptoh/actions/workflows/4.publish-npm.yml/badge.svg \n[url-publish]: https://github.com/heliomarpm/cryptoh/actions/workflows/4.publish-npm.yml\n\n\u003c!-- other badges --\u003e\n[url-npm-badge]: https://img.shields.io/npm/v/@heliomarpm/cryptoh.svg\n[url-npm]: https://www.npmjs.com/package/@heliomarpm/cryptoh\n[url-downloads-badge]: https://img.shields.io/npm/dm/@heliomarpm/cryptoh.svg\n[url-downloads]: http://badge.fury.io/js/@heliomarpm/cryptoh.svg\n[url-deepscan-badge]: https://deepscan.io/api/teams/19612/projects/29822/branches/955507/badge/grade.svg\n[url-deepscan]: https://deepscan.io/dashboard#view=project\u0026tid=19612\u0026pid=29822\u0026bid=955507\n[url-codefactor-badge]: https://www.codefactor.io/repository/github/heliomarpm/cryptoh/badge\n[url-codefactor]: https://www.codefactor.io/repository/github/heliomarpm/cryptoh\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheliomarpm%2Fcryptoh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheliomarpm%2Fcryptoh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheliomarpm%2Fcryptoh/lists"}