All Products
Search
Document Center

MaxCompute:MASK_HASH

Last Updated:Mar 26, 2026

Returns a SHA256 hash of a string expression as a 64-character hexadecimal string. The hash is deterministic—identical input values always produce the same hash.

Syntax

mask_hash(<expr>)

Parameters

  • expr: A STRING, CHAR, VARCHAR, or BINARY expression to hash. Required.

Return value

A 64-character hexadecimal string computed with SHA256. Returns null for non-string inputs, including in Hive-compatible mode.

Examples

-- Hash a string value.
select mask_hash("abc");
-- Result:
+------------+
| _c0        |
+------------+
| ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad |
+------------+

-- Non-string input returns null.
select mask_hash(100);
-- Result:
+------------+
| _c0        |
+------------+
| NULL       |
+------------+

Related functions

MASK_HASH is a string function. For more information about functions related to string searches and conversion, see String functions.