I am working in Scala programming language. I want to encrypt entire column of spark sql data frame using SHA-2 algorithm and a random salt
what I have so far is this and it works well
dataFrame.withColumn("ColumnName", sha2(bin(col("ColumnName")), 256))
How can I add salt to this hashing?
Thanks
Try this:
df.withColumn("ColumnName",
sha2(concat_ws("|", lit("left_salt"), bin(col("yourcoltocrypt")), lit("right_salt"))), 256))