Skip to main content

Introduction

The hash_sha1 function returns the SHA-1 hash of a scalar value as a 40-character hexadecimal string. Use it to generate consistent identifiers, detect duplicates across datasets, or fingerprint values for comparison. SHA-1 produces a 160-bit digest that’s faster to compute than SHA-256 while producing a larger output than MD5. SHA-1 is deprecated for cryptographic security use cases, but remains appropriate for non-security tasks such as data deduplication, fingerprinting, and consistent grouping. For security-sensitive hashing, use hash_sha256 or hash_sha512.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
Splunk provides the sha1(X) function that returns a 40-character hex string. APL’s hash_sha1 works the same way.
ANSI SQL has no standard SHA-1 function. PostgreSQL provides encode(digest(value, 'sha1'), 'hex'). APL’s hash_sha1 returns the same 40-character lowercase hex digest.

Usage

Syntax

Parameters

Returns

The SHA-1 hash of source as a 40-character lowercase hexadecimal string.

Use case examples

Anonymize user IDs and count requests per hashed user to protect PII while tracking usage patterns.Query
Run in PlaygroundOutputThe query replaces raw user IDs with SHA-1 hashes before aggregating, so the busiest users are visible without exposing their original identifiers.
  • hash_md5: Returns a 32-character MD5 hex digest. Use hash_md5 when a shorter digest is sufficient and speed is the priority.
  • hash_sha256: Returns a 64-character SHA-256 hex digest. Use hash_sha256 for security-sensitive hashing.
  • hash_sha512: Returns a 128-character SHA-512 hex digest for maximum hash strength.
  • hash: Returns a signed 64-bit integer hash. Use hash when you need a compact numeric key rather than a hex string.