{"id":13526911,"url":"https://github.com/marc136/node-folder-hash","last_synced_at":"2025-05-15T15:08:00.141Z","repository":{"id":2131989,"uuid":"45772716","full_name":"marc136/node-folder-hash","owner":"marc136","description":"Create a hash checksum over a folder or a file","archived":false,"fork":false,"pushed_at":"2025-03-06T19:49:19.000Z","size":467,"stargazers_count":115,"open_issues_count":11,"forks_count":18,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-08T07:05:56.541Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marc136.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2015-11-08T08:28:38.000Z","updated_at":"2025-05-05T13:38:23.000Z","dependencies_parsed_at":"2024-01-13T23:01:38.729Z","dependency_job_id":"71083cef-23e1-41dc-8f8e-db8b0958c56f","html_url":"https://github.com/marc136/node-folder-hash","commit_stats":{"total_commits":182,"total_committers":11,"mean_commits":"16.545454545454547","dds":0.4505494505494505,"last_synced_commit":"d3df702c7dd6154226cf25c978dc324d6ab2e484"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marc136%2Fnode-folder-hash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marc136%2Fnode-folder-hash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marc136%2Fnode-folder-hash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marc136%2Fnode-folder-hash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marc136","download_url":"https://codeload.github.com/marc136/node-folder-hash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254364270,"owners_count":22058878,"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-08-01T06:01:37.283Z","updated_at":"2025-05-15T15:07:55.131Z","avatar_url":"https://github.com/marc136.png","language":"JavaScript","readme":"﻿Create a hash checksum over a folder or a file.  \nThe hashes are propagated upwards, the hash that is returned for a folder is generated over all the hashes of its children.  \nThe hashes are generated with the _sha1_ algorithm and returned in _base64_ encoding by default.\n\nEach file returns a name and a hash, and each folder returns additionally an array of children (file or folder elements).\n\n## Usage\n\nFirst, install folder-hash with `npm install --save folder-hash` or `yarn add folder-hash`.\n\n### Simple example\n\nTo see differences to the last version of this package, I would create hashes over all _.js_ and _.json_ files. But ignore everything inside folders starting with a dot, and also from the folders _node_modules_, _test_coverage_. The structure of the options object is documented \u003ca href=\"#options\"\u003ebelow.\u003c/a\u003e  \nThis example is also stored in [./examples/readme-example1.js](/examples/readme-example1.js).\n\n```js\nconst { hashElement } = require('folder-hash');\n\nconst options = {\n  folders: { exclude: ['.*', 'node_modules', 'test_coverage'] },\n  files: { include: ['*.js', '*.json'] },\n};\n\nconsole.log('Creating a hash over the current folder:');\nhashElement('.', options)\n  .then(hash =\u003e {\n    console.log(hash.toString());\n  })\n  .catch(error =\u003e {\n    return console.error('hashing failed:', error);\n  });\n```\n\nThe returned information looks for example like this:\n\n```\nCreating a hash over the current folder:\n{ name: '.', hash: 'YZOrKDx9LCLd8X39PoFTflXGpRU=,'\n  children: [\n    { name: 'examples', hash: 'aG8wg8np5SGddTnw1ex74PC9EnM=,'\n      children: [\n        { name: 'readme-example1.js', hash: 'Xlw8S2iomJWbxOJmmDBnKcauyQ8=' }\n        { name: 'readme-with-callbacks.js', hash: 'ybvTHLCQBvWHeKZtGYZK7+6VPUw=' }\n        { name: 'readme-with-promises.js', hash: '43i9tE0kSFyJYd9J2O0nkKC+tmI=' }\n        { name: 'sample.js', hash: 'PRTD9nsZw3l73O/w5B2FH2qniFk=' }\n      ]}\n    { name: 'index.js', hash: 'kQQWXdgKuGfBf7ND3rxjThTLVNA=' }\n    { name: 'package.json', hash: 'w7F0S11l6VefDknvmIy8jmKx+Ng=' }\n    { name: 'test', hash: 'H5x0JDoV7dEGxI65e8IsencDZ1A=,'\n      children: [\n        { name: 'parameters.js', hash: '3gCEobqzHGzQiHmCDe5yX8weq7M=' }\n        { name: 'test.js', hash: 'kg7p8lbaVf1CPtWLAIvkHkdu1oo=' }\n      ]}\n  ]}\n```\n\nAnd the structure may be traversed to e.g. create incremental backups.\n\nIt is also possible to only match the full path and not the basename. The same configuration could look like this:  \n_You should be aware that \\*nix and Windows behave differently, so please use caution._\n\n```js\nconst options = {\n  folders: {\n    exclude: ['.*', '**.*', '**node_modules', '**test_coverage'],\n    matchBasename: false,\n    matchPath: true,\n  },\n  files: {\n    //include: ['**.js', '**.json' ], // Windows\n    include: ['*.js', '**/*.js', '*.json', '**/*.json'], // *nix\n    matchBasename: false,\n    matchPath: true,\n  },\n};\n```\n\n### Parameters for the hashElement function\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eName\u003c/th\u003e\n            \u003cth\u003eType\u003c/th\u003e\n            \u003cth\u003eAttributes\u003c/th\u003e\n            \u003cth\u003eDescription\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n            \u003ctd\u003ename\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003estring\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n            \u003c/td\u003e\n            \u003ctd\u003eelement name or an element's path\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003edir\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003estring\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd\u003edirectory that contains the element (generated from name if omitted)\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eoptions\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003eObject\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u003ca href=\"#options\"\u003eOptions object (see below)\u003c/a\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003ecallback\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003efn\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd\u003eError-first callback function\u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n## Options\n\n### Default values\n\n```js\n{\n    algo: 'sha1',       // see crypto.getHashes() for options in your node.js REPL\n    algoOptions: {},    // Allowed for some algorithms, see https://nodejs.org/api/crypto.html#cryptocreatehashalgorithm-options\n    encoding: 'base64', // 'base64', 'base64url', 'hex' or 'binary'\n    files: {\n        exclude: [],\n        include: [],\n        matchBasename: true,\n        matchPath: false,\n        ignoreBasename: false,\n        ignoreRootName: false\n    },\n    folders: {\n        exclude: [],\n        include: [],\n        matchBasename: true,\n        matchPath: false,\n        ignoreRootName: false\n    },\n    symbolicLinks: {\n        include: true,\n        ignoreBasename: false,\n        ignoreTargetPath: true,\n        ignoreTargetContent: false,\n        ignoreTargetContentAfterError: false,\n    }\n}\n```\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eName\u003c/th\u003e\n            \u003cth\u003eType\u003c/th\u003e\n            \u003cth\u003eAttributes\u003c/th\u003e\n            \u003cth\u003eDefault\u003c/th\u003e\n            \u003cth\u003eDescription\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n            \u003ctd\u003ealgo\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003estring\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                'sha1'\n            \u003c/td\u003e\n            \u003ctd\u003echecksum algorithm, see options in \u003ca href=\"https://nodejs.org/api/crypto.html#cryptogethashes\"\u003ecrypto.getHashes()\u003c/a\u003e\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003ealgoOptions\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003eObject\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                {}\n            \u003c/td\u003e\n            \u003ctd\u003echecksum algorithm options, see \u003ca href=\"https://nodejs.org/api/crypto.html#cryptocreatehashalgorithm-options\"\u003edocs\u003c/a\u003e\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eencoding\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003estring\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                'base64'\n            \u003c/td\u003e\n            \u003ctd\u003eencoding of the resulting hash. One of 'base64', 'base64url', 'hex' or 'binary'\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003efiles\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003eObject\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd colspan=\"2\"\u003e\n                \u003ca href=\"#rules-object-properties\"\u003eRules object (see below)\u003c/a\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003efolders\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003eObject\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd colspan=\"2\"\u003e\n                \u003ca href=\"#rules-object-properties\"\u003eRules object (see below)\u003c/a\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003esymLinks\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003eObject\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd colspan=\"2\"\u003e\n                \u003ca href=\"#symlink-options\"\u003eSymlink options (see below)\u003c/a\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n#### Rules object properties\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eName\u003c/th\u003e\n            \u003cth\u003eType\u003c/th\u003e\n            \u003cth\u003eAttributes\u003c/th\u003e\n            \u003cth\u003eDefault\u003c/th\u003e\n            \u003cth\u003eDescription\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eexclude\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003eArray.\u0026lt;string\u0026gt; || Function\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                []\n            \u003c/td\u003e\n            \u003ctd\u003eArray of optional exclude glob patterns, see \u003ca href=\"https://github.com/isaacs/minimatch#features\"\u003eminimatch doc\u003c/a\u003e. Can also be a function which returns true if the passed file is excluded.\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003einclude\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003eArray.\u0026lt;string\u0026gt; || Function\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                []\n            \u003c/td\u003e\n            \u003ctd\u003eArray of optional include glob patterns, see \u003ca href=\"https://github.com/isaacs/minimatch#features\"\u003eminimatch doc\u003c/a\u003e. Can also be a function which returns true if the passed file is included.\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003ematchBasename\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003ebool\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                true\n            \u003c/td\u003e\n            \u003ctd\u003eMatch the glob patterns to the file/folder name\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003ematchPath\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003ebool\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                false\n            \u003c/td\u003e\n            \u003ctd\u003eMatch the glob patterns to the file/folder path\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eignoreBasename\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003ebool\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                false\n            \u003c/td\u003e\n            \u003ctd\u003eSet to true to calculate the hash without the basename element\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eignoreRootName\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003ebool\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u0026lt;optional\u0026gt;\u003cbr\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                false\n            \u003c/td\u003e\n            \u003ctd\u003eSet to true to calculate the hash without the basename of the root (first) element\u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n### Symlink options\n\nConfigure how symbolic links should be hashed.  \nTo understand how the options can be combined to create a specific behavior, look into [test/symbolic-links.js](https://github.com/marc136/node-folder-hash/blob/master/test/symbolic-links.js).\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eName\u003c/th\u003e\n            \u003cth\u003eType\u003c/th\u003e\n            \u003cth\u003eDefault\u003c/th\u003e\n            \u003cth\u003eDescription\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n            \u003ctd\u003einclude\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003ebool\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                true\n            \u003c/td\u003e\n            \u003ctd\u003eIf false, symbolic links are not handled at all. A folder with three symbolic links inside will have no children entries.\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eignoreBasename\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003ebool\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                false\n            \u003c/td\u003e\n            \u003ctd\u003eSet to true to calculate the hash without the basename element\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eignoreTargetPath\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003ebool\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                true\n            \u003c/td\u003e\n            \u003ctd\u003eIf false, the resolved link target is added to the hash (uses \u003ca href=\"https://devdocs.io/node/fs#fs_fs_readlink_path_options_callback\"\u003efs.readlink\u003c/a\u003e)\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eignoreTargetContent\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003ebool\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                false\n            \u003c/td\u003e\n            \u003ctd\u003eIf true, will only assess the basename and target path (as configured in the other options)\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eignoreTargetContentAfterError\u003c/td\u003e\n            \u003ctd\u003e\n                \u003cspan\u003ebool\u003c/span\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                false\n            \u003c/td\u003e\n            \u003ctd\u003eIf true, will ignore all errors while trying to hash symbolic links and only assess the basename and target path (as configured in other options).\u003cbr /\u003eE.g. a missing target (\u003ci\u003eENOENT\u003c/i\u003e) or access permissions (\u003ci\u003eEPERM\u003c/i\u003e).\u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n## Command line usage\n\nAfter installing it globally via\n\n```\n$ npm install -g folder-hash\n```\n\nYou can use it like this:\n\n```\n# local folder\n$ folder-hash -c config.json .\n# local folder\n$ folder-hash\n# global folder\n$ folder-hash /user/bin\n```\n\nIt also allows to pass an optional JSON configuration file with the `-c` or `--config` flag, which should contain the same configuration as when using the JavaScript API.\n\nYou can also use a local version of folder-hash like this:\n\n```\n$ npx folder-hash --help\nUse folder-hash on cli like this:\n  folder-hash [--config \u003cjson-file\u003e] \u003cfile-or-folder\u003e\n```\n\n## Examples\n\n### Other examples using promises\n\nSee file _./examples/readme-with-promises.js_\n\n```js\nconst path = require('path');\nconst { hashElement } = require('folder-hash');\n\n// pass element name and folder path separately\nhashElement('test', path.join(__dirname, '..'))\n  .then(hash =\u003e {\n    console.log('Result for folder \"../test\":', hash.toString(), '\\n');\n  })\n  .catch(error =\u003e {\n    return console.error('hashing failed:', error);\n  });\n\n// pass element path directly\nhashElement(__dirname)\n  .then(hash =\u003e {\n    console.log(`Result for folder \"${__dirname}\":`);\n    console.log(hash.toString(), '\\n');\n  })\n  .catch(error =\u003e {\n    return console.error('hashing failed:', error);\n  });\n\n// pass options (example: exclude dotFolders)\nconst options = { encoding: 'hex', folders: { exclude: ['.*'] } };\nhashElement(__dirname, options)\n  .then(hash =\u003e {\n    console.log('Result for folder \"' + __dirname + '\" (with options):');\n    console.log(hash.toString(), '\\n');\n  })\n  .catch(error =\u003e {\n    return console.error('hashing failed:', error);\n  });\n```\n\n### Other examples using error-first callbacks\n\nSee _./examples/readme-with-callbacks.js_\n\n```js\nconst path = require('path');\nconst { hashElement } = require('folder-hash');\n\n// pass element name and folder path separately\nhashElement('test', path.join(__dirname, '..'), (error, hash) =\u003e {\n  if (error) {\n    return console.error('hashing failed:', error);\n  } else {\n    console.log('Result for folder \"../test\":', hash.toString(), '\\n');\n  }\n});\n\n// pass element path directly\nhashElement(__dirname, (error, hash) =\u003e {\n  if (error) {\n    return console.error('hashing failed:', error);\n  } else {\n    console.log('Result for folder \"' + __dirname + '\":');\n    console.log(hash.toString(), '\\n');\n  }\n});\n\n// pass options (example: exclude dotFiles)\nconst options = { algo: 'md5', files: { exclude: ['.*'], matchBasename: true } };\nhashElement(__dirname, options, (error, hash) =\u003e {\n  if (error) {\n    return console.error('hashing failed:', error);\n  } else {\n    console.log('Result for folder \"' + __dirname + '\":');\n    console.log(hash.toString());\n  }\n});\n\n// pass algoOptions (example: shake256)\n// see https://nodejs.org/api/crypto.html#cryptocreatehashalgorithm-options\n// only supported in node v12.8 and higher\nconst options = { algo: 'shake256', algoOptions: { outputLength: 5 }, files: { exclude: ['.*'], matchBasename: true } };\nhashElement(__dirname, options, (error, hash) =\u003e {\n  if (error) {\n    return console.error('hashing failed:', error);\n  } else {\n    console.log('Result for folder \"' + __dirname + '\":');\n    console.log(hash.toString());\n  }\n});\n```\n\n## Behavior\n\nThe behavior is documented and verified in the unit tests. Execute `npm test` or `mocha test`, and have a look at the _test_ subfolder.  \nYou can also have a look at the [test suite report page](https://github.com/marc136/node-folder-hash/actions/workflows/node.js.yml)\n\n### Creating hashes over files (with default options)\n\n**The hashes are the same if:**\n\n- A file is checked again\n- Two files have the same name and content (but exist in different folders)\n\n**The hashes are different if:**\n\n- A file was renamed or its content was changed\n- Two files have the same name but different content\n- Two files have the same content but different names\n\n### Creating hashes over folders (with default options)\n\nContent means in this case a folder's children - both the files and the subfolders with their children.\n\n**The hashes are the same if:**\n\n- A folder is checked again\n- Two folders have the same name and content (but have different parent folders)\n\n**The hashes are different if:**\n\n- A file somewhere in the directory structure was renamed or its content was changed\n- Two folders have the same name but different content\n- Two folders have the same content but different names\n\n## License\n\nMIT, see LICENSE.txt\n","funding_links":[],"categories":["Repository"],"sub_categories":["Filesystem"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarc136%2Fnode-folder-hash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarc136%2Fnode-folder-hash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarc136%2Fnode-folder-hash/lists"}