Skip to main content

Introduction

The hash_sha256 function returns the SHA-256 hash of a scalar value as a 64-character hexadecimal string. Use it for security-sensitive hashing, compliance requirements, data integrity checks, or any scenario where cryptographic strength is needed. SHA-256 produces a 256-bit digest and is the current industry standard for secure hashing. Unlike MD5 and SHA-1, SHA-256 isn’t practically vulnerable to collision attacks, making it appropriate for use in security workflows such as verifying log integrity, fingerprinting malware indicators, or hashing credentials. For even longer digests, use 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 sha256(X) function that returns a 64-character hex string. APL’s hash_sha256 works the same way.
ANSI SQL has no standard SHA-256 function. PostgreSQL provides encode(digest(value, 'sha256'), 'hex'). APL’s hash_sha256 returns the same 64-character lowercase hex digest.

Usage

Syntax

Parameters

Returns

The SHA-256 hash of source as a 64-character lowercase hexadecimal string.

Use case examples

Anonymize user IDs with a cryptographically strong hash before publishing usage summaries.Query
Run in PlaygroundOutputThe query replaces user IDs with SHA-256 hashes before aggregating, producing a privacy-safe summary of the most active users.
  • hash_sha512: Returns a 128-character SHA-512 hex digest. Use hash_sha512 when your security policy requires a longer digest than SHA-256.
  • hash_sha1: Returns a 40-character SHA-1 hex digest. SHA-1 is deprecated for security use; prefer hash_sha256.
  • hash_md5: Returns a 32-character MD5 hex digest. MD5 is not cryptographically safe; use hash_sha256 for security contexts.
  • hash: Returns a signed 64-bit integer hash. Use hash when you need a compact numeric key rather than a hex string.