Home / Search/ Language Reference/ Functions/ Scalar Functions/ Hash Functions/hash_sha256

hash_sha256

The hash_sha256 function returns a SHA-256 hash value for the input value.

Syntax

    hash_sha256( Source )

Arguments

  • Source: The value to be hashed.

Returns

The SHA-256 hash value of the given scalar, encoded as a hex string (a string of characters, each two of which represent a single Hex number between 0 and 255).

Examples

  • h1=hash_sha256("World")
  • h2=hash_sha256(datetime(2020-01-01))

Aggregate by hash

This example uses the hash_sha256 function to aggregate StormEvents based on the State’s SHA-256 hash value.

dataset=StormEvents
| summarize StormCount = count() by State, StateHash=hash_sha256(State)
| top 5 by StormCount desc

Returns the following:

StateStateHashStormCount
TEXAS9087f20f23f91b5a77e8406846117049029e6798ebbd0d38aea68da73a00ca374701
KANSASc80e328393541a3181b258cdb4da4d00587c5045e8cf3bb6c8fdb7016b69cc2e3166
IOWAf85893dca466f779410f65cd904fdc4622de49e119ad4e7c7e4a291ceed1820b2337
ILLINOISae3eeabfd7eba3d9a4ccbfed6a9b8cff269dc43255906476282e0184cf81b7fd2022
MISSOURId15dfc28abc3ee73b7d1f664a35980167ca96f6f90e034db2a6525c0b8ba61b12016