pyspark.sql.functions.sha2¶

pyspark.sql.functions.sha2(col, numBits)[source]

Returns the hex string result of SHA-2 family of hash functions (SHA-224, SHA-256, SHA-384, and SHA-512). The numBits indicates the desired bit length of the result, which must have a value of 224, 256, 384, 512, or 0 (which is equivalent to 256).

New in version 1.5.0.

Examples

>>> digests = df.select(sha2(df.name, 256).alias('s')).collect()
>>> digests[0]