I have written Hive UDF in Java for decoding the information, for that we used the below code.
public Text evaluate(Text str) throws Exception {
byte[] keyBytes = (SALT + KEY).getBytes("UTF8");
MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
keyBytes = messageDigest.digest(keyBytes);
keyBytes = java.util.Arrays.copyOf(keyBytes, 16);
SecretKeySpec key = new SecretKeySpec(keyBytes, "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, key);
String decryptedString = Base64.encodeBase64String(cipher.doFinal(str.getBytes()));
return new Text(decryptedString);
}
The below query is executed successfully with UDF.
below is the Gender table where I'm executing the UDF
When I execute the query on the gender table with UDF, I'm getting the null and new line in it. Please find the below screenshot with highlighted areas.
I'm expecting the result in one line only. Please help and let me know where I'm wrong.