{"id":13465018,"url":"https://github.com/lovell/farmhash","last_synced_at":"2025-05-15T11:03:26.547Z","repository":{"id":474003,"uuid":"24855076","full_name":"lovell/farmhash","owner":"lovell","description":"Node.js implementation of FarmHash, Google's family of high performance hash functions","archived":false,"fork":false,"pushed_at":"2024-09-17T19:50:03.000Z","size":175,"stargazers_count":449,"open_issues_count":3,"forks_count":32,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-03T20:08:51.247Z","etag":null,"topics":["checksum","farmhash","fingerprint","hash","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lovell.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":"2014-10-06T16:57:37.000Z","updated_at":"2025-03-20T21:43:29.000Z","dependencies_parsed_at":"2024-09-17T23:42:44.541Z","dependency_job_id":null,"html_url":"https://github.com/lovell/farmhash","commit_stats":{"total_commits":109,"total_committers":15,"mean_commits":7.266666666666667,"dds":"0.13761467889908252","last_synced_commit":"93074a99b9115034b09510fa54413602ab32a52e"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovell%2Ffarmhash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovell%2Ffarmhash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovell%2Ffarmhash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovell%2Ffarmhash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lovell","download_url":"https://codeload.github.com/lovell/farmhash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248441815,"owners_count":21104079,"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":["checksum","farmhash","fingerprint","hash","nodejs"],"created_at":"2024-07-31T14:00:55.195Z","updated_at":"2025-04-11T16:38:32.734Z","avatar_url":"https://github.com/lovell.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# farmhash\n\nNode.js implementation of Google's\n[FarmHash](https://github.com/google/farmhash)\nfamily of very fast hash functions.\n\nFarmHash is the successor to CityHash.\nFunctions in the FarmHash family are not suitable for cryptography.\nA fast, cryptographically-secure alternative is\n[HighwayHash](https://github.com/lovell/highwayhash).\n\nThe 32-bit methods return a `Number`,\nthe 64-bit methods return a `BigInt`\nand the 128-bit methods are not implemented.\n\nThis module uses FarmHash v1.1.0 (2015-03-01).\nIt has been tested with Node.js 16, 18, 20 and 22\non Linux (glibc, musl),\nmacOS (x64, arm64) and\nWindows (x86, x64).\n\nPre-compiled binaries are provided for\nIntel CPUs with SSE4.2 intrinsics\nand Apple ARM64 CPUs.\nUse the `npm install --build-from-source` flag to gain performance benefits\non more modern CPUs such as those with AVX intrinsics.\n\n## Installation\n\n```sh\nnpm install farmhash\n```\n\n```sh\nyarn add farmhash\n```\n\n```sh\npnpm add farmhash\n```\n\n## Usage\n\n```javascript\nconst farmhash = require('farmhash');\n```\n\n```javascript\nconst hash = farmhash.hash32('test');\nconsole.log(typeof hash); // 'number'\n```\n\n```javascript\nconst hash = farmhash.hash64(new Buffer('test'));\nconsole.log(typeof hash); // 'bigint'\n```\n\n```javascript\nconst hash = farmhash.hash64WithSeed('test', 123);\nconsole.log(typeof hash); // 'bigint'\n```\n\n```javascript\nconst hash = farmhash.fingerprint32(new Buffer('test'));\nconsole.log(typeof hash); // 'number'\n```\n\n```javascript\nconst hash = farmhash.fingerprint64('test');\nconsole.log(typeof hash); // 'bigint'\n```\n\n```javascript\nconst hash = farmhash.fingerprint64signed('test');\nconsole.log(typeof hash); // 'bigint'\n```\n\n## API\n\n### Hash\n\nThe hash methods are platform dependent.\nDifferent CPU architectures, for example 32-bit vs 64-bit, Intel vs ARM, SSE4.2 vs AVX\nmight produce different results for a given input.\n\n#### hash32(input)\n\n* `input` is the `Buffer` or `String` to hash.\n\nReturns a `Number` containing the 32-bit unsigned integer hash value of `input`.\n\n#### hash32WithSeed(input, seed)\n\n* `input` is the `Buffer` or `String` to hash.\n* `seed` is an integer Number to use as a seed.\n\nReturns a `Number` containing the 32-bit unsigned integer hash value of `input`.\n\n#### hash64(input)\n\n* `input` is the `Buffer` or `String` to hash.\n\nReturns a `BigInt` containing the 64-bit unsigned integer hash value of `input`.\n\n#### hash64WithSeed(input, seed)\n\n* `input` is the `Buffer` or `String` to hash.\n* `seed` is an integer `Number` to use as a seed.\n\nReturns a `BigInt` containing the 64-bit unsigned integer hash value of `input`.\n\n#### hash64WithSeeds(input, seed1, seed2)\n\n* `input` is the `Buffer` or `String` to hash.\n* `seed1` and `seed2` are both an integer `Number` to use as seeds.\n\nReturns a `BigInt` containing the 64-bit unsigned integer hash value of `input`.\n\n### Fingerprint\n\nThe fingerprint methods are platform independent, producing the same results for a given input on any machine.\n\n#### fingerprint32(input)\n\n* `input` is the `Buffer` or `String` to fingerprint.\n\nReturns a `Number` containing the 32-bit unsigned integer fingerprint value of `input`.\n\n#### fingerprint64(input)\n\n* `input` is the `Buffer` or `String` to fingerprint.\n\nReturns a `BigInt` containing the 64-bit unsigned integer fingerprint value of `input`.\n\n#### fingerprint64signed(input)\n\n* `input` is the `Buffer` or `String` to fingerprint.\n\nReturns a `BigInt` containing the 64-bit signed integer fingerprint value of `input`.\n\nThis matches the signed behaviour of Google BigQuery's\n[FARM_FINGERPRINT](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#farm_fingerprint)\nfunction.\n\n## Testing\n\n```sh\nnpm test\n```\n\n## Licence\n\nCopyright 2014 Lovell Fuller and contributors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n     https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\nCopyright 2014, 2015, 2016, 2017 Google, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovell%2Ffarmhash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flovell%2Ffarmhash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovell%2Ffarmhash/lists"}