Decrypt Value From Outside Source in Azure Databricks

Jaganathan, Naveen 31 Reputation points
2022-12-15T11:55:09.037+00:00

Hi Team,

I am Getting a value from On-Prem(AB Initio ETL tool) with Encrypted using below function from thier end....

m_eval 'string_to_hex(encrypt_aes_simple("Field-value","{Key}"))'
"DEB48636106FEEEFB1CEA0DD26F2CE2D"

I want to decrypt the value in Azure Databricks...

I tried below and was getting error

val hex = spark.sql("""select aes_decrypt(decode(unhex("DEB48636106FEEEFB1CEA0DD26F2CE2D"),"UTF-8"),'{key}') AS VALUE""")

SparkRuntimeException: The value of parameter(s) 'expr, key' in the aes_encrypt/aes_decrypt function is invalid: Detail message: Input too short - need tag

Please suggest a solution for the same....

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,371 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. KranthiPakala-MSFT 46,612 Reputation points Microsoft Employee
    2022-12-16T07:29:28.937+00:00

    Hello @Jaganathan, Naveen ,

    Thanks for the question and using MS Q&A platform.

    As the error message clearly says, that the value you provided for the encrypted binary expression parameter (nothing but Field-value in your example) is not correct or incomplete or shorter than it has to be which is why you are seeing the above error message.

    I tried to reproduce the same using a sample below and was able to reproduce the issue by passing a shorter binary expression parameter value while decrypting. Please see below

    271297-image.png

    But when I have provided the accurate/correct encrypted binary expression parameter value for the decryption, then it works as expected. Please see below:

    271226-image.png

    Hence, I would recommend making sure you are passing the correct encrypted binary expression parameter value to aes_decrypt() function.

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.