{"id":18785800,"url":"https://github.com/itzshoaib/hashtegrity","last_synced_at":"2026-03-07T00:30:44.306Z","repository":{"id":257809247,"uuid":"867318068","full_name":"ITZSHOAIB/hashtegrity","owner":"ITZSHOAIB","description":"A library for generating hash, validating data integrity, monitoring file/directory integrity, offchain data integrity","archived":false,"fork":false,"pushed_at":"2025-05-26T22:03:58.000Z","size":469,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T06:21:22.352Z","etag":null,"topics":["crypto-hash","data","data-integrity","hacktoberfest","hash","integrity"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/hashtegrity","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/ITZSHOAIB.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","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,"zenodo":null}},"created_at":"2024-10-03T20:47:50.000Z","updated_at":"2025-02-26T17:59:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"2cde37c2-388c-4234-962a-4158a6dc65d0","html_url":"https://github.com/ITZSHOAIB/hashtegrity","commit_stats":null,"previous_names":["itzshoaib/hashtegrity"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/ITZSHOAIB/hashtegrity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ITZSHOAIB%2Fhashtegrity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ITZSHOAIB%2Fhashtegrity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ITZSHOAIB%2Fhashtegrity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ITZSHOAIB%2Fhashtegrity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ITZSHOAIB","download_url":"https://codeload.github.com/ITZSHOAIB/hashtegrity/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ITZSHOAIB%2Fhashtegrity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30204154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-hash","data","data-integrity","hacktoberfest","hash","integrity"],"created_at":"2024-11-07T20:49:41.686Z","updated_at":"2026-03-07T00:30:44.279Z","avatar_url":"https://github.com/ITZSHOAIB.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌟 Hashtegrity 🌟\n\n**Secure your data with ease!** `Hashtegrity` is a powerful library for generating hashes and validating data integrity, ensuring your data remains untampered and secure.\n\n## 🚀 Features\n\n- **Verifiable Hash List**: Create and verify **Merkle trees** for large list of data. Generate proof and verify efficiently.\n- **Versatile Hashing**: Supports multiple hashing algorithms like `sha256`, `md5`, and more.\n- **HMAC Generation**: Easily generate HMACs for added security.\n- **Data Integrity Validation**: Validate the integrity of your data with simple functions.\n- **File Integrity Validation**: Validate the integrity of your file easily.\n- **File Integrity Monitoring**: Monitor file changes and validate integrity in real-time.\n- **TypeScript Support**: Fully typed for a seamless development experience.\n\n## 📦 Installation\n\nInstall the package:\n\n```bash\nnpm install hashtegrity\n```\n\n## 🛠️ Usage\n\n### VerifiableHashList \n\nThe `VerifiableHashList` feature allows you to create and verify Merkle trees for data integrity. This is particularly useful for ensuring the integrity of a list of items very efficiently.\n\n```typescript\nimport { VerifiableHashList } from \"hashtegrity\";\n\n// Create a verifiable hash list\nconst hashList = new VerifiableHashList([\"item1\", \"item2\"]);\n\n// Get the root hash of the Merkle tree\n// **Which can be stored onchain\nconst rootHash = hashList.getRootHash();\nconsole.log(\"Root Hash:\", rootHash);\n\n// Add an item to the list\nconst newRootHash = hashList.addItem(\"item3\");\nconsole.log(\"New Root Hash:\", newRootHash);\n\n// Verify an item in the list\nconst isValid = hashList.verifyItem(\"item3\", newRootHash);\nconsole.log(\"Is Valid:\", isValid);\n\n// Serialize the hash list into JSON\n// **can be stored offchain\nconst json = hashList.toJSON();\nconsole.log(\"Serialized Hash List:\", json);\n\n// Deserialize the hash list and again convert into VerifiableHashList instance\nconst deserializedHashList = VerifiableHashList.fromJSON(json);\nconsole.log(\"Deserialized Root Hash:\", \n  deserializedHashList.getRootHash()\n);\n```\n\n### Generate a Hash\n\n```typescript\nimport { generateHash } from \"hashtegrity\";\n\nconst hash = generateHash({ data: { key: \"value\" }, algorithm: \"sha256\" });\n```\n\n### Generate an HMAC\n\n```typescript\nimport { generateHash } from \"hashtegrity\";\n\nconst hmac = generateHash({\n  data: \"message\",\n  key: \"secret-key\",\n  algorithm: \"sha256\",\n});\n```\n\n### Generate a File Hash\n\n```typescript\nimport { generateFileHash } from \"hashtegrity\";\n\nconst hash = await generateFileHash({\n  filePath: \"path/to/your/file.txt\",\n  algorithm: \"sha256\",\n});\n```\n\n### Generate Directory Hash\n\n```typescript\nimport { generateDirectoryHash } from 'hashtegrity';\n\nconst hash = await generateDirectoryHash({\n  directoryPath: \"path/to/directory\",\n});\n```\n\n### Validate Data Integrity\n\n```typescript\nimport { validateIntegrity } from 'hashtegrity';\n\nconst isValid = await validateIntegrity({\n  type: \"data\",\n  data: \"your-data-of-any-type\",\n  expectedHash: \"4d4f638fd1c15eb71e1c7b46556c6d76cf6cc0cf1961d9e39a5fdc988a22cfe2\",\n  algorithm: \"sha256\",\n});\n```\n\n### Validate File Integrity\n\n```typescript\nimport { validateIntegrity } from 'hashtegrity';\n\nconst isValid = await validateIntegrity({\n  type: \"file\",\n  filePath: \"path/to/your/file.txt\",\n  expectedHash: \"4d4f638fd1c15eb71e1c7b46556c6d76cf6cc0cf1961d9e39a5fdc988a22cfe2\",\n  algorithm: \"sha256\",\n});\n```\n\n### Validate Directory Integrity\n\n```typescript\nimport { validateIntegrity } from 'hashtegrity';\n\nconst isValid = await validateIntegrity({\n  type: \"directory\",\n  filePath: \"path/to/your/directory\",\n  expectedHash: \"4d4f638fd1c15eb71e1c7b46556c6d76cf6cc0cf1961d9e39a5fdc988a22cfe2\",\n  algorithm: \"sha256\",\n});\n```\n\n### Monitor File Integrity\n\n```typescript\nimport { monitorIntegrity } from 'hashtegrity';\n\nconst options = {\n  type: \"file\",\n  filePath: \"path/to/your/file.txt\",\n  algorithm: \"sha256\",\n  key: \"your-secret-key\",\n  metadata: { custom: \"data\" },\n  expectedHash:\n    \"4d4f638fd1c15eb71e1c7b46556c6d76cf6cc0cf1961d9e39a5fdc988a22cfe2\",\n  onIntegrityCheckFailed: (error) =\u003e {\n    console.error(\"Integrity check failed:\", error);\n  },\n  onError: (error) =\u003e {\n    console.error(\"Error:\", error);\n  },\n};\n\nawait monitorIntegrity(options);\nconsole.log(\"Monitoring started\");\n```\n\n### Monitor Directory Integrity\n\n```typescript\nimport { monitorIntegrity } from 'hashtegrity';\n\nconst options = {\n  type: \"directory\",\n  filePath: \"path/to/your/directory\",\n  algorithm: \"sha256\",\n  key: \"your-secret-key\",\n  metadata: { custom: \"data\" },\n  expectedHash:\n    \"4d4f638fd1c15eb71e1c7b46556c6d76cf6cc0cf1961d9e39a5fdc988a22cfe2\",\n  onIntegrityCheckFailed: (error) =\u003e {\n    console.error(\"Integrity check failed:\", error);\n  },\n  onError: (error) =\u003e {\n    console.error(\"Error:\", error);\n  },\n};\n\nawait monitorIntegrity(options);\nconsole.log(\"Monitoring started\");\n```\n\n## 🤝 Contribution\n\nWe welcome contributions! Please see the [CONTRIBUTING.md](.github/CONTRIBUTING.md) file for detailed guidelines on how to contribute.\n\n\n## 📜 License\n\nThis project is licensed under the MIT License. See the [LICENSE file](/LICENSE) for details.\n\n\n---\n\nCreated with ❤️ by Sohab Sk\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzshoaib%2Fhashtegrity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitzshoaib%2Fhashtegrity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzshoaib%2Fhashtegrity/lists"}