pyspark.sql.functions.aes_decrypt¶
- 
pyspark.sql.functions.aes_decrypt(input: ColumnOrName, key: ColumnOrName, mode: Optional[ColumnOrName] = None, padding: Optional[ColumnOrName] = None, aad: Optional[ColumnOrName] = None) → pyspark.sql.column.Column[source]¶
- Returns a decrypted value of input using AES in mode with padding. Key lengths of 16, 24 and 32 bits are supported. Supported combinations of (mode, padding) are (‘ECB’, ‘PKCS’), (‘GCM’, ‘NONE’) and (‘CBC’, ‘PKCS’). Optional additional authenticated data (AAD) is only supported for GCM. If provided for encryption, the identical AAD value must be provided for decryption. The default mode is GCM. - New in version 3.5.0. - Parameters
- inputColumnor str
- The binary value to decrypt. 
- keyColumnor str
- The passphrase to use to decrypt the data. 
- modeColumnor str, optional
- Specifies which block cipher mode should be used to decrypt messages. Valid modes: ECB, GCM, CBC. 
- paddingColumnor str, optional
- Specifies how to pad messages whose length is not a multiple of the block size. Valid values: PKCS, NONE, DEFAULT. The DEFAULT padding means PKCS for ECB, NONE for GCM and PKCS for CBC. 
- aadColumnor str, optional
- Optional additional authenticated data. Only supported for GCM mode. This can be any free-form input and must be provided for both encryption and decryption. 
 
- input
 - Examples - >>> df = spark.createDataFrame([( ... "AAAAAAAAAAAAAAAAQiYi+sTLm7KD9UcZ2nlRdYDe/PX4", ... "abcdefghijklmnop12345678ABCDEFGH", "GCM", "DEFAULT", ... "This is an AAD mixed into the input",)], ... ["input", "key", "mode", "padding", "aad"] ... ) >>> df.select(aes_decrypt( ... unbase64(df.input), df.key, df.mode, df.padding, df.aad).alias('r') ... ).collect() [Row(r=bytearray(b'Spark'))] - >>> df = spark.createDataFrame([( ... "AAAAAAAAAAAAAAAAAAAAAPSd4mWyMZ5mhvjiAPQJnfg=", ... "abcdefghijklmnop12345678ABCDEFGH", "CBC", "DEFAULT",)], ... ["input", "key", "mode", "padding"] ... ) >>> df.select(aes_decrypt( ... unbase64(df.input), df.key, df.mode, df.padding).alias('r') ... ).collect() [Row(r=bytearray(b'Spark'))] - >>> df.select(aes_decrypt(unbase64(df.input), df.key, df.mode).alias('r')).collect() [Row(r=bytearray(b'Spark'))] - >>> df = spark.createDataFrame([( ... "83F16B2AA704794132802D248E6BFD4E380078182D1544813898AC97E709B28A94", ... "0000111122223333",)], ... ["input", "key"] ... ) >>> df.select(aes_decrypt(unhex(df.input), df.key).alias('r')).collect() [Row(r=bytearray(b'Spark'))]