{"_id":"djb2a","_rev":"6-80c203beb97d1c032ec7d1611ff49250","name":"djb2a","dist-tags":{"latest":"3.0.0"},"versions":{"1.0.0":{"name":"djb2a","version":"1.0.0","keywords":["djb2a","djb2","djb","algorithm","hash","hashing","string","function","bernstein"],"author":{"url":"sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"djb2a@1.0.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/djb2a#readme","bugs":{"url":"https://github.com/sindresorhus/djb2a/issues"},"dist":{"shasum":"516c12c51b3f7aad64d604dbd4d588c6623e91c5","tarball":"https://registry.npmjs.org/djb2a/-/djb2a-1.0.0.tgz","integrity":"sha512-KsqihKd9Fd054umuQln8l8jd5AFELBuyS14YCLhGR/RSSPg4tjf3NCv5MPDWvcNe9x6DTz7XP+Zrd4eyHXND0g==","signatures":[{"sig":"MEUCIQD19SL7VJAguRv3s2ATn+nUNn2HjzDNnrqkS6i8yM/zkgIgezG70aB46V+sSBRpVHDs/Hf/owXuuyON6SYc0RIU7us=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"files":["index.js"],"engines":{"node":">=6"},"gitHead":"0a141f33ca52676a865f2213ca55806ba4eeb8d6","scripts":{"test":"xo && ava"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/djb2a.git","type":"git"},"_npmVersion":"5.5.1","description":"DJB2a non-cryptographic hash function","directories":{},"_nodeVersion":"8.9.0","devDependencies":{"xo":"*","ava":"*"},"_npmOperationalInternal":{"tmp":"tmp/djb2a-1.0.0.tgz_1515286904864_0.6967415406834334","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"djb2a","version":"1.1.0","keywords":["djb2a","djb2","djb","algorithm","hash","hashing","string","function","bernstein"],"author":{"url":"sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"djb2a@1.1.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/djb2a#readme","bugs":{"url":"https://github.com/sindresorhus/djb2a/issues"},"dist":{"shasum":"1dc388143c86b5526e6558f25ed963159e9c7bf0","tarball":"https://registry.npmjs.org/djb2a/-/djb2a-1.1.0.tgz","fileCount":5,"integrity":"sha512-cXB1qncibP/TyIbn3PiFTFt6g5HliJNP6WSUA90+v9DsMi4kc8GpOmB89cKeHJ0FfUP1v4O7gV4En5XaHXQ7Xw==","signatures":[{"sig":"MEUCIE72pWxtE4tZimn+Mg69tudRUBfzRB9RgG7WHcxyy6ZJAiEAlP7ubHRdW+/9EUnwT/iE9JRw0f6yunva4Xu/w/5u7HQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3183,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcj0q5CRA9TVsSAnZWagAAzeYP/RBsGwzY2hQUlOaZrcxf\n1pg/2SoXPTE75BJGV9fSxnciF3rlhKc0T97Kc0znhBXGaaAINObW0v65PMCL\ncPnPZADuXq6CjTtTeew4mbL1F4plS/ZT/4mzmYDnH77wc16MQem2kCSfnw5z\n2EqXwhk2aIS6n/qs8ZMdkIWgipA0mhpVj9gI1somtwNjqd4VXXe3vArbZH3M\n6VfdFUjSoN3fDLzfJbpZOb5VzsQUwAU8xHkNZsxZUljmPDJHPi7FwbeOP8al\nv8CY+4ZRb/WaJ7MXlWu5PIl3Wg642Rkhyzx6rlnhaTQycLFnksOyYF+/c9dO\n2xUmYAhpgIagG20BelyqBIrWTMkSIMCxF5NC4bFydwmFdMlUoMGLUwaxK5Zi\nb/DFzeRTMk6ogjR0Ota5u7JOms9HVF61wU7RoCbUmPfKnuuJA2Vdo9PyMsUL\nLMoYb9q3jVxNRH0Qqnz1r0wo31QGFm1ZGZDY1aJZdMEzv+EzS8Nh/+cQsnfq\nLiaZS5feAZt+ZxckZzILR7luNYUHPjU2ZmXFHkIgvEuSoTTCjEkv4xD1HSBy\n1XwewxHLEhthe3TuNTnBybiOgZ1yHMWYNwW8kpAuNErhuVf9CT6JcJtP+xdk\nVmoecUjj9svD3oD6R4w/0y6+NQ5H65SZbI4vI/vadiYcPBm/e4lQpeK4Gifx\nDRNK\r\n=mMDP\r\n-----END PGP SIGNATURE-----\r\n"},"engines":{"node":">=6"},"gitHead":"3d7ae649df61c32b3f2615469b9a4ca991a1b3d9","scripts":{"test":"xo && ava && tsd-check"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/djb2a.git","type":"git"},"_npmVersion":"6.9.0","description":"DJB2a 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/djb2a_1.1.0_1552894648441_0.43273727837740905","host":"s3://npm-registry-packages"}},"1.2.0":{"name":"djb2a","version":"1.2.0","keywords":["djb2a","djb2","djb","algorithm","hash","hashing","string","function","bernstein"],"author":{"url":"sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"djb2a@1.2.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/djb2a#readme","bugs":{"url":"https://github.com/sindresorhus/djb2a/issues"},"dist":{"shasum":"a441d5f49b90b78aac52d2c44f5a6c49b3d1724b","tarball":"https://registry.npmjs.org/djb2a/-/djb2a-1.2.0.tgz","fileCount":5,"integrity":"sha512-rXrJYOPCGvHPYw8R2u/zczFTG3xXNqklrtT17vTPm8n/4a16PKEhrfgMwJ9Zyuz96PJwZzHuK2ChQO/SSChuKA==","signatures":[{"sig":"MEUCIQD13KVZaPVJFJ7l+2NHp5luMopOJSWMdq55pZFR7hGQJwIgTMvN+XZf2cLvbA0kZOFssVuWIkf/z0sDaYlUeOVhHQ8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3510,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcoLAACRA9TVsSAnZWagAAwUUP/37iaenpQHl1uE40I85o\nbtNZc+ot8Fy8NISOsdg1JYfR/b48WfAa/jLMuFXsAMo92RwZLqZSDUo5l2ye\n6jGRkiUXdKfnu9wr/9Ap4qxSvpyboU7Wv3ORzSjU8kFqwJWgPH8UASJe3Ayc\nK8a3l8gArBfquhr4bptEO4X9ngvVAF4e46WDGMvZ0CJ7zRoC418Yt+7es5JF\nYDMT9OUUEeprV4T74rq9A6OBgYy8bRMxzOW/RTTKqDGbUFVyQRaovpFtSnuA\nRwWfCt9Ul41WGXE6ywu8wR2S3bmawRVx04hqxIGyHKk2x6ofzqgeOwq1BeU+\nSWrggMC7pWMG4sNywkGvaNumf4lWFKUBmEuBUndPjztimqGYvNHSNqDo2Da5\n3y2Ecg8+UYRoqRD/XeBTje+BhXtSU01CcZvhcCeMR0Ccbf9b3XPzCsYrXibp\nnp3PpuwyYURcjtVBdE1ndz7/CUH7fZSU4Kb9HLpnktOaa8zCcGLivfqWg3SS\n7J+hwGRbkkK9ubaK9ggC8CXxxlZv2YWShLuF9a3NDUKcAr7oOPV/ntRlv6r0\n5liPfn0x6d8RAHoiA37Q2sxmefL/e/m6Pl3SQVIvRYVZ2/QDKMFgaBJGzUbQ\nvjluVP8YHkkT0qw3vp7H6sWjbCb5AAph16QF7F+0zMf5zSbOPz5PaEJQ9SU+\nD9Ax\r\n=83WO\r\n-----END PGP SIGNATURE-----\r\n"},"engines":{"node":">=6"},"gitHead":"73d683a051a74dda665f4404111c7dae9a43933c","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/djb2a.git","type":"git"},"_npmVersion":"6.9.0","description":"DJB2a 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/djb2a_1.2.0_1554034687526_0.8672409029639556","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"djb2a","version":"2.0.0","keywords":["djb2a","djb2","djb","algorithm","hash","hashing","string","function","bernstein"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"djb2a@2.0.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/djb2a#readme","bugs":{"url":"https://github.com/sindresorhus/djb2a/issues"},"dist":{"shasum":"63ad541b06b821de4b81ea7d59420cad76ce41aa","tarball":"https://registry.npmjs.org/djb2a/-/djb2a-2.0.0.tgz","fileCount":5,"integrity":"sha512-mSkCTNSJRGjNUADzWx1ubTGxJh2IVY9uoc/WGozUIu0mgBUEvIyBn9uTs9jqFBbJxQthJMF3uDx0cnpdlAUo4Q==","signatures":[{"sig":"MEQCIDr5X7kkkaPSVhMHDIiSnEvU8LuYRSodXX3G5kmuZsF2AiBwBB6QdYEXgpkOkUHDVXwGqGhBOVl5N699YHBbmpCBGQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3139,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgd831CRA9TVsSAnZWagAANRwP/RybIM0IxA6gMnVxUpQ2\n1+2zFa1MkPC7TtMVHcNaF5XRFwbpGJpVojMfR6p/0VhKxrg0wRlS9r+6I4Qb\nHeuCmow6ZAgjxGUS2XCkbXCZR5NOsTFuEX7a0eryyY6ACVR8OmbBCtiHM0ow\npQYfp0it4zTDyHftaaKdNrTgmV5JE/FM0XgaOJZToaEieiEjW82P8flEZey9\n/UquKWMdYeF+UI7sZVvNB+/Jp8O3RxEzjVXe+esFmMayLwh1JHsEGdsDQ6a2\nfoCRJHZaAPUbmLRhF9LT3rUbnkk1KmoAu2svpP1zrvSLyJXdKHFiMOWAkdFe\npnqjX8bgdZSCcvI2Nb25oAsxFdIsw1BKgzKLpdj0p8S8rNPIMTPY87Ted+oQ\nfYFL2i6VQ8ArDdf5T81s7WdUasX3DU+y4yoFCp2SMeSDw5L+Dh+DewNdL5jm\nc/Cerie/6faaMppf0BV7wTTgI13onEXfxO7zqefecfpvtDKqwHc4rXQIvLLF\nuFKCQTmktgmcHgc4aGDLd/JZmqopIDC3TSOOYabf72y5FhwqsqB1CY2udF2u\nJaQ4DU1GGxZqOMbsaDNDWa9ddBETuX5XlmkMFmUZ55TXUzYt5Qez4J72JX+t\nYQAzKNYR5mkxa+Qu9WAB+Yj1zxc1UtAxWwe3yeJ9zNrLVAG43zSk2L5eg56h\nMC03\r\n=BYp+\r\n-----END PGP SIGNATURE-----\r\n"},"type":"module","engines":{"node":">=12"},"exports":"./index.js","funding":"https://github.com/sponsors/sindresorhus","gitHead":"67fa4558ffbb8916b55e57aa4d21abe65da40c7a","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/djb2a.git","type":"git"},"_npmVersion":"6.14.10","description":"DJB2a non-cryptographic hash function","directories":{},"_nodeVersion":"15.12.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.38.2","ava":"^3.15.0","tsd":"^0.14.0"},"_npmOperationalInternal":{"tmp":"tmp/djb2a_2.0.0_1618464244776_0.22774264172003322","host":"s3://npm-registry-packages"}},"3.0.0":{"name":"djb2a","version":"3.0.0","description":"DJB2a non-cryptographic hash function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/djb2a.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":["djb2a","djb2","djb","algorithm","hash","hashing","string","function","bernstein"],"devDependencies":{"ava":"^6.4.1","xo":"^1.2.2"},"xo":{"rules":{"no-bitwise":"off"}},"_id":"djb2a@3.0.0","gitHead":"d29ab7448857f0ef2f50dcd32624d8c4e171fc13","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/djb2a/issues"},"homepage":"https://github.com/sindresorhus/djb2a#readme","_nodeVersion":"20.19.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-jshrXsoimTmhSWbTzAZoLWb8dvCzvB6FZPW25XVofkt2GuZ0A4nPDSsMZGXBVL+aRoxFjJn8ORgrZCNO7DmPQw==","shasum":"49a413940ac35830b84971028eb499b5e3cb2706","tarball":"https://registry.npmjs.org/djb2a/-/djb2a-3.0.0.tgz","fileCount":5,"unpackedSize":7034,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFZSIt1UDn6DrsWdMbbO3CwfSALPBnLlegw8e76CKfiWAiA9FXkb8RqIPnVCAbgZqIFwGaz5AGf3an84nIQ1F+gwpw=="}]},"_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/djb2a_3.0.0_1757888506956_0.02632126438397231"},"_hasShrinkwrap":false}},"time":{"created":"2018-01-07T01:01:44.951Z","modified":"2025-09-14T22:21:47.351Z","1.0.0":"2018-01-07T01:01:44.951Z","1.1.0":"2019-03-18T07:37:28.601Z","1.2.0":"2019-03-31T12:18:07.667Z","2.0.0":"2021-04-15T05:24:04.966Z","3.0.0":"2025-09-14T22:21:47.141Z"},"bugs":{"url":"https://github.com/sindresorhus/djb2a/issues"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","homepage":"https://github.com/sindresorhus/djb2a#readme","keywords":["djb2a","djb2","djb","algorithm","hash","hashing","string","function","bernstein"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/djb2a.git"},"description":"DJB2a non-cryptographic hash function","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"readme":"# djb2a\n\n> [DJB2a](http://www.cse.yorku.ca/~oz/hash.html#djb2) non-cryptographic hash function\n\n[DJB2a 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 djb2a\n```\n\n## Usage\n\n```js\nimport djb2a from 'djb2a';\n\n// Hash a string (UTF-16 code units by default)\ndjb2a('🦄🌈');\n//=> 1484783307\n\n// Hash a string as UTF-8 bytes for cross-language compatibility\ndjb2a('🦄🌈', {bytes: true});\n//=> 1642026147\n\n// Hash bytes directly\ndjb2a(new Uint8Array([1, 2, 3]));\n//=> 193375973\n\n// Return a 64-bit BigInt instead of a 32-bit number\ndjb2a.bigint('🦄🌈');\n//=> 5779750603n\n\n// BigInt with UTF-8 bytes\ndjb2a.bigint('🦄🌈', {bytes: true});\n//=> 7564289453806755n\n```\n\n## API\n\n### djb2a(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 DJB2a implementations in other languages, which typically operate on UTF-8 bytes.\n\n### djb2a.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 DJB2a 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- [sdbm](https://github.com/sindresorhus/sdbm) - SDBM non-cryptographic hash function\n","readmeFilename":"readme.md"}