{"_id":"sdbm","_rev":"6-dc112c0175b8b488fff83825dc71a636","name":"sdbm","dist-tags":{"latest":"3.0.0"},"versions":{"1.0.0":{"name":"sdbm","version":"1.0.0","keywords":["sdbm","algorithm","hash","hashing","string","function"],"author":{"url":"sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"sdbm@1.0.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/sdbm#readme","bugs":{"url":"https://github.com/sindresorhus/sdbm/issues"},"dist":{"shasum":"2ff411271779b9d5e3d74105d1f2d085d3dcd344","tarball":"https://registry.npmjs.org/sdbm/-/sdbm-1.0.0.tgz","integrity":"sha512-29rNjvF5r6FzNsaL6w/UM9Gmw0I4kDlTerQZKHwop1fMKAXWcHxnfLNIX6Z2Zy/jM8s5tJjdx51+CKbfaunFyA==","signatures":[{"sig":"MEYCIQC7zecNzcg9ywXmUCKbANVZnLsBnnks1Ry5WKSwFLHJaAIhAKnXjp1qW3gwHP/KTTEnNvYe5Rg0/y+1swgZu9RnldeS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"files":["index.js"],"engines":{"node":">=6"},"gitHead":"5480e64db14debd8b0449e65448fd28683517aef","scripts":{"test":"xo && ava"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/sdbm.git","type":"git"},"_npmVersion":"5.5.1","description":"SDBM non-cryptographic hash function","directories":{},"_nodeVersion":"8.9.0","devDependencies":{"xo":"*","ava":"*"},"_npmOperationalInternal":{"tmp":"tmp/sdbm-1.0.0.tgz_1515285340685_0.5339200680609792","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"sdbm","version":"1.1.0","keywords":["sdbm","algorithm","hash","hashing","string","function"],"author":{"url":"sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"sdbm@1.1.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/sdbm#readme","bugs":{"url":"https://github.com/sindresorhus/sdbm/issues"},"dist":{"shasum":"69cd56001875a42e449adf0742f2ef990f38d0ed","tarball":"https://registry.npmjs.org/sdbm/-/sdbm-1.1.0.tgz","fileCount":5,"integrity":"sha512-ScXaj9Gr4P3clss+um3IAog7fMy+4zvTTQkAzD5PpiA3pdyfbwm3wlMsYv6hsku5hZkjMmMfEQgYQVUMFwD4Jg==","signatures":[{"sig":"MEUCIAD6Zn8YLzglZ6K3o1vBtiFwI7+1NVWXJNfsZtwJbXDhAiEAsHV0YfHwynTC7dhB2DD2jRbjc6+LKT7qEM/5WRaMeCs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":2990,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcj0sCCRA9TVsSAnZWagAATSQP/RGppGxqvwaH9muKdm6h\nlKwN15lUf/eT386W7EiNPYBgkvISCU5XEOYn2j4Vl9atJ6ZlwSvMByNvD2T/\n6Q37hrbUCiFUWe3ZtVxezWbkeCUqfsQQGi/DqoPd6C/fxnPDo53QiNbuYbRP\nnYsJCsISo8arjKp1sagUapGXStvGgWDzZSMdTMHxUULzRheV8D+1lVOtd8yM\nmjvv3dD3Am2GLO7zkZISYjVe06qroVV2lAM+SZo5/3hmk5Ilirt/Eekjxv0n\nsUpvm8ESvwDCtuqZi6fYtrI0L/palseUgezUd3dAcUAeejQd7kIS5MNTws0q\nRhP2rDT480mXoz3IuKftHJ///75h+XHUtY1G5kiqafNDv9KXwraDkj2NuNRa\nEAnlA1qf8Dky6VyC80OLWRhfQaw/AAeIh7V7P5FW1fzrIOmxdZRr0gtMh6gW\n25wgKkxl5E33WcK/tDeimpAtvoV8JGJDqAIeNV8M+G6bcfBFZYIa/cj2Mqia\nEP8dgu/QuHrlSPYNjdZhMhCIAZ6LMiinGe2ttUHYwSap5VaqBHdU/Xjj2Kh5\nHDFaUj08I6iwiXmNP5PRAhU3Qd09PrurW4n5GhW2dy60f2KRsLL7SuO+0dGL\npnLpwHrRwly9UAcqR/5VD0GKxtbeflvi3c6fFlmRq/1U+w9OTMwvunJfvxbE\nfI/s\r\n=3N7X\r\n-----END PGP SIGNATURE-----\r\n"},"engines":{"node":">=6"},"gitHead":"a22a3ce242881ad7b7a40ded0c30bbd215661ec2","scripts":{"test":"xo && ava && tsd-check"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/sdbm.git","type":"git"},"_npmVersion":"6.9.0","description":"SDBM non-cryptographic hash function","directories":{},"_nodeVersion":"8.15.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.24.0","ava":"^1.3.1","tsd-check":"^0.5.0"},"_npmOperationalInternal":{"tmp":"tmp/sdbm_1.1.0_1552894722457_0.6977890007523653","host":"s3://npm-registry-packages"}},"1.2.0":{"name":"sdbm","version":"1.2.0","keywords":["sdbm","algorithm","hash","hashing","string","function"],"author":{"url":"sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"sdbm@1.2.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/sdbm#readme","bugs":{"url":"https://github.com/sindresorhus/sdbm/issues"},"dist":{"shasum":"03e37f22546c7d55ece4df163d3ee19749e27db4","tarball":"https://registry.npmjs.org/sdbm/-/sdbm-1.2.0.tgz","fileCount":5,"integrity":"sha512-YD3wLOPCkHEXfR9rUAQeaC57uLFI0Z2bgzcXx8dFTOfidA6ezp0W6A050DQ2ETlXHpu9+BWey4DS9dKsMyy5Fg==","signatures":[{"sig":"MEYCIQC6uBgk7qlEsasM3oR2cUo8kfpgAUMKc34XOMpRJOp/QgIhAJSSX91Z5QOX1GLu7YLYvMjxBtjOlrX1t1n7wrLyceff","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3310,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcoLYKCRA9TVsSAnZWagAAdAwP/0Ec5Tz8MkT9xr0wtIur\nS+40H27GzeCxMl3OV5PPgtk5ci380kunc6wakoKkjhirp9fvwaDsA2oX2ee3\nNDpscyyMFkPBG4m99wojtDlopAi7HlUwUq5NNM7oBZqAkvwyLIkg2cgsJYfd\nrdKOLn6JXX2EHgySnrISWlCvv9865bek/t1eI3mH+z2cjLBkCsDlqxZ/M29+\nJsFswq953Hfs2Vzf4WyPskrGFXyQYVjXi8gv9FiPB0+qjjy6ZVFufEvvq6Xi\nlD4bX4AUo/G7pbLJabQDYXY9/ac21hh4X06yJnYGlTDoZOaEE5/+mXEIWCiW\nscvs8aLltDD0F74yRe4PXC7Ku4okuAqLh4Ho77YP//+i+fLS0uyPreCrqSCI\nFxCFl4veMxN19coELo4LXt2khybBjEMMNHCO74nUIow+q65PkGt0eadc/B2v\n3dzNHqXItrEmCyPlHiSndE8T7C85vjZd0B14n2bK2aRNECd41kIyA/CAH/GB\nUCxb1sGmuvadWbScq0lZcVzxxo+Za0QlHUshctlgjVArksTeQSBy/9RSPeKA\n4p7j2ioKteEvtlpWFibVDi/PbC4E2wG6u3ufwWWE/gZqU0vkMQSOGCqCMfuN\ndRFifLLezf4LpvXCZOQDM8E/5K+/9v+Gk6Wyc+rVoxCZP560HuoHHAyJQFt7\nJNjU\r\n=BaUJ\r\n-----END PGP SIGNATURE-----\r\n"},"engines":{"node":">=6"},"gitHead":"dbcbaf6351b26fbefd33c27b8e9104c7ac73d22e","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/sdbm.git","type":"git"},"_npmVersion":"6.9.0","description":"SDBM non-cryptographic hash function","directories":{},"_nodeVersion":"8.15.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.24.0","ava":"^1.4.1","tsd":"^0.7.1"},"_npmOperationalInternal":{"tmp":"tmp/sdbm_1.2.0_1554036233394_0.08900429371317964","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"sdbm","version":"2.0.0","keywords":["sdbm","algorithm","hash","hashing","string","function"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"sdbm@2.0.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/sdbm#readme","bugs":{"url":"https://github.com/sindresorhus/sdbm/issues"},"dist":{"shasum":"23828c1195e341d0f5810c59dfa60d86278f8718","tarball":"https://registry.npmjs.org/sdbm/-/sdbm-2.0.0.tgz","fileCount":5,"integrity":"sha512-dspMGxvHiwSTgyrmm90jHQV2sDqK46ssbDK+bQAlJ5aRuPo3C7So108V6rCuCDbm1CrNWuPeMpmTNQKPl7vO+A==","signatures":[{"sig":"MEUCIHWkJdwC/KX8C9LvjezT1paGm4XkhVkQovFsAO022Z0LAiEA16fccG8k8zGGTzRe0nxiJG/6mo2sgWGqNGfu0wQkQOc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":2931,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbWUlCRA9TVsSAnZWagAAeCEP/0OZfBNlUlafmJuW8ucd\nkxJ7pwug8Y7aCl5n5J+Nv/sl2845o3Tp7U4XQbLAx9+l+sksUaYDlhsNm/aO\nyrci5wgjMfxdDcjlTDZE1ScaplEuOf78DtQtexB74QFqpmPndoVF4BNZZPjR\nmcaBdW3D+3cDhBZ+6txANAUvsaTlalvBJD/4eH2lAetJqTSk32rM9ubeIF5J\nJ52rFERB9HllphvS0MgtLqnIrjiCTz67epjC21dDfGB5RHBwbdlVJ3nj0kyV\nc0oDUiI87AFR1De5nCKDYo8jirRXYY5SCgPfGVABDEKKFyhchKktmDX9GKj2\nRWs7ae5bXiUGD02FkvWJiVXOCpE3h667hwmilVTMOdHDGxr2Z1RaVkUO2ehM\nCL8Bkx63cRNYZZ8x2ykJ3l70K/k+I16FMN4Xt+CFNpbnTLORo79rEr3Oz8e1\n6gXCStLKdDalbYazVXbKtMesMjJszlnLoF0WWpjtksBERxSo/n8OHmNXO1R0\nkJVTkb6uy3HrppXPd8ELLBb6jVrF83CnGZ6fPPRKGyS0/IDAA+MOn4WH3j2u\nWy5wvlNDxEKD3pmjTq8ahK8WSdezegyFrag+/IQCDFXoPPA4gFSUIjlAs5Ln\ncXSTisHJhWrMoeOEZQ4JDdlTLcePc+R2WKVvUMElUMMhdEfcE1v/UR9PM5O0\nv9lO\r\n=oTZx\r\n-----END PGP SIGNATURE-----\r\n"},"type":"module","engines":{"node":">=12"},"exports":"./index.js","funding":"https://github.com/sponsors/sindresorhus","gitHead":"d89de6eb634802e93bc381dd7d3f0abb55960e0e","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/sdbm.git","type":"git"},"_npmVersion":"6.14.10","description":"SDBM non-cryptographic hash function","directories":{},"_nodeVersion":"12.20.1","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.38.2","ava":"^3.15.0","tsd":"^0.14.0"},"_npmOperationalInternal":{"tmp":"tmp/sdbm_2.0.0_1617782052874_0.34519886518624676","host":"s3://npm-registry-packages"}},"3.0.0":{"name":"sdbm","version":"3.0.0","description":"SDBM non-cryptographic hash function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/sdbm.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"test":"xo && ava"},"keywords":["sdbm","algorithm","hash","hashing","string","function"],"devDependencies":{"ava":"^6.4.1","xo":"^1.2.2"},"xo":{"rules":{"no-bitwise":"off"}},"_id":"sdbm@3.0.0","gitHead":"93dd7bec2939a28e72da0706ad962bb86108aaa7","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/sdbm/issues"},"homepage":"https://github.com/sindresorhus/sdbm#readme","_nodeVersion":"20.19.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-9FHNk9qJKuRxkUeQQdRp8WLCFaL4hvPtYz/2xNAOkuZzQ3ZqMMkZ1CrkKPDA4lxbenMml0JRKHGyTyucK/JBBg==","shasum":"5e0b66d169b8503a721a93b75e4042e4161469a7","tarball":"https://registry.npmjs.org/sdbm/-/sdbm-3.0.0.tgz","fileCount":5,"unpackedSize":6111,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIB5PpN57+YMeoiMNL2xlgKzvTDTXMhxvR9TnsbIB0UImAiEA8BGrRu3lS6BNaAUVof6fHEMH8ZX7fE0ai1/s3ePWpUQ="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdbm_3.0.0_1757971065500_0.10109629396772668"},"_hasShrinkwrap":false}},"time":{"created":"2018-01-07T00:35:41.607Z","modified":"2025-09-15T21:17:45.861Z","1.0.0":"2018-01-07T00:35:41.607Z","1.1.0":"2019-03-18T07:38:42.580Z","1.2.0":"2019-03-31T12:43:53.518Z","2.0.0":"2021-04-07T07:54:12.978Z","3.0.0":"2025-09-15T21:17:45.672Z"},"bugs":{"url":"https://github.com/sindresorhus/sdbm/issues"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","homepage":"https://github.com/sindresorhus/sdbm#readme","keywords":["sdbm","algorithm","hash","hashing","string","function"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/sdbm.git"},"description":"SDBM non-cryptographic hash function","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"readme":"# sdbm\n\n> [SDBM](http://www.cse.yorku.ca/~oz/hash.html#sdbm) non-cryptographic hash function\n\n[SDBM has good distribution and collisions are rare.](https://softwareengineering.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed/145633#145633)\n\nThe implementation uses [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) internally for precision, avoiding integer overflow issues that can occur with JavaScript's regular number type when processing long strings.\n\n## Install\n\n```sh\nnpm install sdbm\n```\n\n## Usage\n\n```js\nimport sdbm from 'sdbm';\n\n// Hash a string (UTF-16 code units by default)\nsdbm('🦄🌈');\n//=> 4053542802\n\n// Hash a string as UTF-8 bytes for cross-language compatibility\nsdbm('🦄🌈', {bytes: true});\n//=> 958678968\n\n// Hash bytes directly\nsdbm(new Uint8Array([1, 2, 3]));\n//=> 8392706\n\n// Return a 64-bit BigInt instead of a 32-bit number\nsdbm.bigint('🦄🌈');\n//=> 15627115794743961490n\n\n// BigInt with UTF-8 bytes\nsdbm.bigint('🦄🌈', {bytes: true});\n//=> 3515396257032193976n\n```\n\n## API\n\n### sdbm(input, options?)\n\nReturns the hash as a positive 32-bit integer.\n\n#### input\n\nType: `string | Uint8Array`\n\nThe input to hash. Strings are hashed as UTF-16 code units by default (see `options.bytes` to change this).\n\n#### options\n\nType: `object`\n\n##### bytes\n\nType: `boolean`\\\nDefault: `false`\n\nInterpret the string as UTF-8 encoded bytes instead of UTF-16 code units.\n\nThis provides compatibility with SDBM implementations in other languages, which typically operate on UTF-8 bytes.\n\n### sdbm.bigint(input, options?)\n\nReturns the hash as a positive 64-bit BigInt.\n\nAccepts the same arguments as the main function.\n\n## Implementation notes\n\nBy default, this implementation processes strings as UTF-16 code units using JavaScript's `charCodeAt` method. This makes it a JavaScript-specific variant of SDBM that differs from the original C implementation (which operates on bytes) for non-ASCII characters.\n\nUse the `bytes` option to encode strings as UTF-8 for compatibility with other language implementations.\n\n## Related\n\n- [fnv1a](https://github.com/sindresorhus/fnv1a) - FNV-1a non-cryptographic hash function\n- [djb2a](https://github.com/sindresorhus/djb2a) - DJB2a non-cryptographic hash function\n","readmeFilename":"readme.md"}