{"id":21238710,"url":"https://github.com/shahradelahi/sha256","last_synced_at":"2025-04-05T14:03:28.776Z","repository":{"id":246489572,"uuid":"820716222","full_name":"shahradelahi/sha256","owner":"shahradelahi","description":"🔑 SHA-256 Hashing for JavaScript","archived":false,"fork":false,"pushed_at":"2025-03-29T07:39:56.000Z","size":111,"stargazers_count":104,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T22:55:39.125Z","etag":null,"topics":["compare","hmac-sha256","javascript","sha256"],"latest_commit_sha":null,"homepage":"https://npmjs.com/@se-oss/sha256","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/shahradelahi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-27T03:28:55.000Z","updated_at":"2025-03-26T06:40:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"729e4062-6d4b-46b5-8b19-b98d2a8035cb","html_url":"https://github.com/shahradelahi/sha256","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"a144aadc46024203254db9a171434bc6026293d1"},"previous_names":["shahradelahi/sha256"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fsha256","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fsha256/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fsha256/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fsha256/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shahradelahi","download_url":"https://codeload.github.com/shahradelahi/sha256/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345850,"owners_count":20924102,"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":["compare","hmac-sha256","javascript","sha256"],"created_at":"2024-11-21T00:37:51.056Z","updated_at":"2025-04-05T14:03:28.742Z","avatar_url":"https://github.com/shahradelahi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @se-oss/sha256\n\n[![CI](https://github.com/shahradelahi/sha256/actions/workflows/ci.yml/badge.svg)](https://github.com/shahradelahi/sha256/actions/workflows/ci.yml)\n[![NPM Version](https://img.shields.io/npm/v/@se-oss/sha256.svg)](https://www.npmjs.com/package/@se-oss/sha256)\n[![MIT License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](/LICENSE)\n[![Install Size](https://packagephobia.com/badge?p=@se-oss/sha256)](https://packagephobia.com/result?p=@se-oss/sha256)\n![Edge Runtime Compatible](https://img.shields.io/badge/edge--runtime-%E2%9C%94%20compatible-black)\n\nA lightweight JavaScript library that provides utilities for `SHA-256` and `HMAC-SHA-256` hashing. This library is designed to work seamlessly in any JavaScript runtime, offering efficient and straightforward functions for cryptographic hashing.\n\n\u003e [!WARNING]\n\u003e\n\u003e This library is noticeably slower than native modules such as [`node:crypto`](https://nodejs.org/api/crypto.html) and [WebCrypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API). Use this library only when you cannot use WebCrypto because its operations are asynchronous and `node:crypto` is not available.\n\n---\n\n- [Installation](#-installation)\n- [Usage](#-usage)\n- [Documentation](#-documentation)\n- [Contributing](#-contributing)\n- [Credits](#-credits)\n- [License](#license)\n\n## 📦 Installation\n\n```bash\nnpm i @se-oss/sha256\n```\n\n## 📖 Usage\n\n```typescript\nimport { hmacSha256, sha256, timeSafeCompare } from '@se-oss/sha256';\n\n// Hashing a string\nconst hash = sha256('Hello, world!');\nconsole.log(hash);\n\n// Hashing a Uint8Array\nconst data = new Uint8Array([1, 2, 3, 4, 5]);\nconst hash2 = sha256(data);\nconsole.log(hash2);\n\n// HMAC with a string key and message\nconst key = 'my-secret-key';\nconst message = 'Hello, HMAC!';\nconst hmac = hmacSha256(key, message);\nconsole.log(hmac);\n\n// HMAC with a Uint8Array key and message\nconst keyArray = new Uint8Array([1, 2, 3, 4, 5]);\nconst hmac2 = hmacSha256(keyArray, 'Hello, HMAC!');\nconsole.log(hmac2);\n\nconst result = timeSafeCompare('hello', 'hello');\nconsole.log(result); // true\n\nconst result2 = timeSafeCompare('hello', 'world');\nconsole.log(result2); // false\n```\n\n## 📚 Documentation\n\nFor all configuration options, please see [the API docs](https://www.jsdocs.io/package/@se-oss/sha256).\n\n##### API\n\n\u003c!-- prettier-ignore --\u003e\n```typescript\ntype BinaryLike = string | Uint8Array | Buffer;\n\nfunction sha256(data: BinaryLike): Uint8Array;\nfunction hmacSha256(key: BinaryLike, message: BinaryLike): Uint8Array;\nfunction timeSafeCompare(a: string, b: string): boolean;\n```\n\n## 🤝 Contributing\n\nWant to contribute? Awesome! To show your support is to star the project, or to raise issues on [GitHub](https://github.com/shahradelahi/sha256).\n\nThanks again for your support, it is much appreciated! 🙏\n\n## 🙌 Credits\n\n- [Andrea Griffini](https://github.com/6502)\n\n## License\n\n[MIT](/LICENSE) © [Shahrad Elahi](https://github.com/shahradelahi) and [contributors](https://github.com/shahradelahi/sha256/graphs/contributors).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahradelahi%2Fsha256","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshahradelahi%2Fsha256","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahradelahi%2Fsha256/lists"}