SHA-1 API

Calculate a SHA-1 digest of UTF-8 text and receive its lowercase hexadecimal representation in JSON.

Try the SHA-1 API

POST /api/v1/sha1-hash/

Send request transmits this input to the API server. The online tool processes input in your browser.

Request parameters

ParameterTypeRequiredRules
textstringYesText hashed exactly as supplied. Spaces, line endings and a trailing newline change the digest. Maximum: 16384 code points.

Response fields

A successful response is {"ok":true,"data":{…}}. These fields are inside data.

algorithm · string
Returned algorithm. Values: SHA-1.
hex · string
40 lowercase hex digits.

Hash exactly the intended bytes

This endpoint hashes the UTF-8 representation of text with SHA-1 and returns 40 lowercase hexadecimal characters. It does not trim whitespace, normalize Unicode or add a newline. When comparing a shell command with this API, use printf rather than echo if echo appends a newline. Visually identical composed and decomposed Unicode strings can have different bytes and therefore different digests.

Choosing the right digest

SHA-1 is provided for compatibility with legacy formats and known checksums. Its collision resistance is broken, so use a modern digest such as SHA-256 for new integrity designs. This endpoint does not calculate HMAC, hash files, sign requests or store passwords. A bare hash does not authenticate the sender.

cURL, JavaScript and Python examples

Known text

A reproducible SHA-1 test vector for checking an integration.

cURL
curl --fail-with-body --request POST 'https://www.base64.sh/api/v1/sha1-hash/' \
  --user-agent 'Base64.sh API example/1.0' --header 'Content-Type: application/json' \
  --data-raw '{"text":"abc"}'
JavaScript
const response = await fetch("https://www.base64.sh/api/v1/sha1-hash/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "text": "abc"
})
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
Python
import json
from urllib.request import Request, urlopen

payload = json.loads("{\n  \"text\": \"abc\"\n}")
request = Request(
    "https://www.base64.sh/api/v1/sha1-hash/",
    data=json.dumps(payload, ensure_ascii=False).encode("utf-8"),
    headers={"Content-Type": "application/json", "User-Agent": "Base64.sh API example/1.0"},
    method="POST",
)
with urlopen(request, timeout=15) as response:
    print(json.load(response))

Response · HTTP 200

{
  "ok": true,
  "data": {
    "algorithm": "SHA-1",
    "hex": "a9993e364706816aba3e25717850c26c9cd0d89d"
  }
}

Empty string

An empty string is valid and has a defined digest.

cURL
curl --fail-with-body --request POST 'https://www.base64.sh/api/v1/sha1-hash/' \
  --user-agent 'Base64.sh API example/1.0' --header 'Content-Type: application/json' \
  --data-raw '{"text":""}'
JavaScript
const response = await fetch("https://www.base64.sh/api/v1/sha1-hash/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "text": ""
})
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
Python
import json
from urllib.request import Request, urlopen

payload = json.loads("{\n  \"text\": \"\"\n}")
request = Request(
    "https://www.base64.sh/api/v1/sha1-hash/",
    data=json.dumps(payload, ensure_ascii=False).encode("utf-8"),
    headers={"Content-Type": "application/json", "User-Agent": "Base64.sh API example/1.0"},
    method="POST",
)
with urlopen(request, timeout=15) as response:
    print(json.load(response))

Response · HTTP 200

{
  "ok": true,
  "data": {
    "algorithm": "SHA-1",
    "hex": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
  }
}

Invalid request example

{
  "text": 123
}

HTTP 400

{
  "ok": false,
  "error": {
    "code": "INVALID_INPUT",
    "message": "text must be a string."
  }
}

Limits and error handling

Requests require Content-Type: application/json and a UTF-8 JSON object. The body limit is 32 KiB (32,768 bytes), text fields allow up to 16,384 Unicode code points unless a smaller limit is listed, and responses are limited to 256 KiB. Unknown parameters and unpaired Unicode surrogates in parameter strings are rejected. Send inputs in the request body, not query parameters.

Anonymous access is limited to approximately 60 POST requests per minute per IP address, shared across endpoints in each Cloudflare location. Shared networks share the allowance. Counters are eventually consistent, not a guaranteed global quota. On HTTP 429, wait for the Retry-After interval before retrying; avoid immediate retry loops.

Programmatic clients should send an identifying User-Agent, as shown in the cURL and Python examples. Browser fetch supplies its own header. Cloudflare may reject a generic or missing agent before the API runs; an edge-generated 403 can be plain text or HTML rather than the JSON envelope. See Cloudflare error 1010.

400 · Invalid input
Malformed JSON, missing fields, unsupported options or invalid encoded text. Correct the input before retrying.
403 · Edge request blocked
Check the User-Agent and the Cloudflare error response before retrying.
404 · Unknown endpoint
Use a documented /api/v1/{tool}/ endpoint.
405 · Method not allowed
Use POST. OPTIONS is supported for browser CORS requests.
413 · Size limit exceeded
Reduce the request size or the generated output.
415 · Unsupported media type
Set Content-Type: application/json.
429 · Rate limited
Wait at least the Retry-After number of seconds.
500 / 503 · Service unavailable
Retry later with bounded backoff. Availability is not guaranteed.

API data processing

API inputs are sent over HTTPS and processed in memory by a Cloudflare Worker. The application does not persist submitted text or deliberately log request bodies, and API responses use Cache-Control: no-store. Cloudflare may process network metadata under its own policies. For local processing, use the corresponding browser tool. See the privacy policy.