ForHosting KIT · Developer Utilities

djb2 hash calculator

Paste a word and get Bernstein's djb2 fingerprint: hello gives 0f923099, or 261238937 as a plain number, the same result textbook code produces. Use it for hash tables, cache keys and stable buckets, never for passwords. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Text
hello
You get
Hash hex
0f923099
Hash int
261,238,937
Hash dec
261238937
Length
5

djb2 is the classic non-cryptographic string hash designed by Daniel J. Bernstein: start at five thousand three hundred eighty-one, then for every character multiply the running hash by thirty-three and add the character code, keeping only the low thirty-two bits. Developers still reach for djb2 when they need a fast, deterministic fingerprint for hash tables, cache keys, deduplication maps, and teaching materials that should match textbooks and well-known code snippets. This capability accepts a non-empty text string, runs that exact algorithm over UTF-16 code units, and returns the thirty-two-bit residual as eight lowercase hexadecimal digits plus the matching unsigned integer.

How djb2 turns text into a number

djb2 was designed by Daniel J. Bernstein and is one of the most copied string hashes. It starts from the number 5381. For every character of the text it multiplies the running total by 33 and adds that character's code, and after each step it keeps only the last 32 bits, so the total always fits in a fixed range. The multiplier is often written as a shift of five bits plus the original value, which gives the same result. The final number is shown two ways: as eight lowercase hexadecimal digits, padded with zeros on the left, and as an ordinary unsigned integer. For the word hello that is 0f923099, or 261238937.

When djb2 fits, and when it does not

djb2 is quick, needs no secret and always gives the same answer for the same text, which makes it handy for hash tables, cache keys, deduplication maps, routing users into stable buckets and classroom exercises that must match the textbook. It is not a password hash and not a check that a file is intact: with only 32 bits, different texts can share a value, and anyone who chooses inputs on purpose can find such clashes. Use a cryptographic hash for that. Empty text is rejected rather than given a fake value, and numbers are hashed as the text you see.

What djb2 is and when a 32-bit string hash is enough

Non-cryptographic hashes trade collision resistance against speed and simplicity. djb2 is one of the most copied of those trade-offs: the seed five thousand three hundred eighty-one and the multiplier thirty-three (often written as a five-bit left shift plus the original value) produce a well-scattered thirty-two-bit integer for ordinary short strings without tables, secrets, or platform dependencies.

Bernstein published the idea in the public domain era of C string utilities; it still appears in language runtimes, game engines, and blog posts because students can implement it in a few lines and still get useful distribution for hash maps. It is not a password hash, not a content-integrity digest, and not a substitute for SHA-two-five-six or BLAKE when an adversary might choose inputs.

Feature flags and routing buckets

Map user or tenant strings into a thirty-two-bit space for consistent A/B buckets without cryptographic overhead or secret material.

How do I compute a djb2 hash?

Send a non-empty string in the text field.

What algorithm and seed does this use?

Classic Daniel J. Bernstein djb2: initial hash 5381, then for each character hash = hash * 33 + charCode, truncated to an unsigned 32-bit value.

Is djb2 suitable for passwords or integrity checks?

No. djb2 is a fast non-cryptographic fingerprint for hash tables and teaching. Use a modern cryptographic hash for passwords, signatures, and content integrity.

Why does my djb2 result differ from another tool?

Usually the other tool skips a step of the classic recipe. This one starts at 5381, multiplies by 33 and adds each character code, then keeps only the unsigned low 32 bits at every step, which is how common reference code gets 0f923099 for hello.

What is a djb2 hash used for?

It gives any text a fast, repeatable number. Developers use it to place keys in hash tables, build cache keys, spot duplicates and split users into consistent test groups, where speed matters more than resistance to attack.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/enc/djb2

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/enc/djb2 \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"hello"}'
{
  "text": "hello"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "enc.djb2",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Empty input is rejected with invalid_input so callers never confuse a zero-length payload with a real hash.

What djb2 is and when a 32-bit string hash is enough

This endpoint hard-codes the classic unsigned thirty-two-bit wrap so that the ASCII word hello yields the familiar residual zero-f-nine-two-three-zero-nine-nine, and the string test yields seven-c-nine-e-six-eight-six-five, matching common reference implementations that truncate with an unsigned cast after each multiply-and-add step.

Input contract, empty-input rejection, and response fields

Numbers and booleans are accepted by coercing them to their string form before hashing, which keeps simple calculator widgets ergonomic. Failed validation is not billed. The algorithm is linear in string length and entirely in-memory; keep browser demos to ordinary human-scale strings, and pin known vectors such as hello equals zero-f-nine-two-three-zero-nine-nine in continuous integration so a one-line refactor cannot silently change the contract. POST a JSON body with the required string field text. The value must be a non-empty string; missing text, null, or an empty string fails with invalid_input and a message that explicitly reports empty or missing input so form UIs can highlight the field without guessing. On success the body includes hash_hex as eight lowercase hexadecimal digits zero-padded on the left, hash_int as the unsigned integer from zero through four billion two hundred ninety-four million nine hundred sixty-seven thousand two hundred ninety-five, hash_dec as the same integer rendered in decimal text, length as the character count of the hashed string, algorithm fixed to djb2, and seed fixed to five thousand three hundred eighty-one documenting the classic initial value. Alias keys data, payload, value, input, and string are accepted for the payload so SDK callers can reuse existing field names.

Where a djb2 hash API earns its keep

Educators and interview coaches use the same deterministic output to grade student implementations of multiply-by-thirty-three hashing without standing up a compiler farm. Content sites that rank for djb2 hash calculator gain a live tool whose free path matches the automation path byte-for-byte. Keep requests deterministic, reject empty payloads at the edge, and you get textbook-grade reproducibility without embedding djb2 snippets in every microservice.

Hash-table and cache-key fingerprints

Hash short identifiers with djb2 and store hash_hex or hash_int as a compact, language-agnostic fingerprint for maps, caches, and bucket assignment.

Teaching and golden-test vectors

Assert that student or library code produces hash_hex 0f923099 for hello and 7c9e6865 for test so ports of djb2 stay aligned across runtimes.

What happens if I send empty text?

Empty or missing text fails with invalid_input and a message that reports empty input. Those failures are not billed.

What does the djb2 hash tool cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →