hash_sha256()hash_sha256()

返回输入值的 sha256 哈希值。Returns a sha256 hash value for the input value.

语法Syntax

hash_sha256(source)hash_sha256(source)

参数Arguments

  • source:要进行哈希处理的值。source: The value to be hashed.

返回Returns

给定标量的 sha256 哈希值编码为十六进制字符串(其中的每两个字符都表示 0 到 255 之间的一个十六进制数字)。The sha256 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).

警告

此函数 (SHA256) 所用的算法可确保不会在以后修改,但计算起来非常复杂。The algorithm used by this function (SHA256) is guaranteed to not be modified in the future, but is very complex to calculate. 建议需要在单个查询期间使用“轻量级”哈希函数的用户改为使用函数 hash()Users that need a "lightweight" hash function for the duration of a single query are advised to use the function hash() instead.

示例Examples

print 
h1=hash_sha256("World"),
h2=hash_sha256(datetime(2020-01-01))
h1h1 h2h2
78ae647dc5544d227130a0682a51e30bc7777fbb6d8a8f17007463a3ecd1d52478ae647dc5544d227130a0682a51e30bc7777fbb6d8a8f17007463a3ecd1d524 ba666752dc1a20eb750b0eb64e780cc4c968bc9fb8813461c1d7e750f302d71dba666752dc1a20eb750b0eb64e780cc4c968bc9fb8813461c1d7e750f302d71d

以下示例使用 hash_sha256() 函数根据 State 的 SHA256 哈希值聚合 StormEvents。The following example uses the hash_sha256() function to aggregate StormEvents based on State's SHA256 hash value.

StormEvents 
| summarize StormCount = count() by State, StateHash=hash_sha256(State)
| top 5 by StormCount desc
状态State StateHashStateHash StormCountStormCount
德克萨斯TEXAS 9087f20f23f91b5a77e8406846117049029e6798ebbd0d38aea68da73a00ca379087f20f23f91b5a77e8406846117049029e6798ebbd0d38aea68da73a00ca37 47014701
堪萨斯州KANSAS c80e328393541a3181b258cdb4da4d00587c5045e8cf3bb6c8fdb7016b69cc2ec80e328393541a3181b258cdb4da4d00587c5045e8cf3bb6c8fdb7016b69cc2e 31663166
衣阿华州IOWA f85893dca466f779410f65cd904fdc4622de49e119ad4e7c7e4a291ceed1820bf85893dca466f779410f65cd904fdc4622de49e119ad4e7c7e4a291ceed1820b 23372337
伊利诺斯州ILLINOIS ae3eeabfd7eba3d9a4ccbfed6a9b8cff269dc43255906476282e0184cf81b7fdae3eeabfd7eba3d9a4ccbfed6a9b8cff269dc43255906476282e0184cf81b7fd 20222022
密苏里州MISSOURI d15dfc28abc3ee73b7d1f664a35980167ca96f6f90e034db2a6525c0b8ba61b1d15dfc28abc3ee73b7d1f664a35980167ca96f6f90e034db2a6525c0b8ba61b1 20162016