hadoop-hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Edward Capriolo (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HIVE-867) Add add UDFs found in mysq
Date Tue, 13 Oct 2009 15:07:31 GMT

    [ https://issues.apache.org/jira/browse/HIVE-867?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12765106#action_12765106
] 

Edward Capriolo commented on HIVE-867:
--------------------------------------

I can use some advice on something. I have been working on the aes_encrypt and the aes_decrypt
functions.

{noformat}
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.*;
   import javax.crypto.*;
   import javax.crypto.spec.*;
   import java.io.*;


public class a {

public static void main(String [] args) throws Exception{
     String data_string="Hello";
     String key_string="123";
     byte [] encrypted = null;
     byte [] decrypted = null;
     StringBuffer buffer = new StringBuffer();
      buffer.append(key_string);
      for (int i=key_string.getBytes("UTF-8").length;i<16;i++){
        buffer.append('\0');
      }
      Cipher cipher = Cipher.getInstance("AES");
      SecretKeySpec skeySpec = new SecretKeySpec(buffer.toString().getBytes("UTF-8"), "A
ES");
      
      cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
      encrypted =cipher.doFinal(data_string.getBytes() );
       System.out.println("en "+encrypted);

      cipher.init(Cipher.DECRYPT_MODE, skeySpec);
      decrypted =cipher.doFinal(encrypted );
      System.out.println("de "+decrypted);
      System.out.println("de2 "+new String(decrypted) );
}
}
{noformat}

I have this working in a stand alone program but I am having some issues getting it to work
as a udf.

{noformat}
select aes_decrypt(aes_encrypt('yo','123'), '123') FROM src LIMIT 1;
{noformat}

Should return 'yo'. I added some debug
{noformat}
  [junit] plan = /tmp/plan9309.xml
    [junit] en [B@1b22920
    [junit] en l16
    [junit] en [B@1aa2c23
    [junit] en l16
    [junit] Classclass java.lang.String
    [junit] en [B@1700391
    [junit] en l16
    [junit] len23
    [junit] data_string�        s�˴�v�-�
    [junit] key123
{noformat}

As you can see from my debug the string seems to be "changing length" between aes_encrypt
and aes_decrypt. 16->23. Is this a serialization conversion thing?

Can I return byte[] rather then string? Any ideas would be VERY appreciated!


> Add add UDFs found in mysq
> --------------------------
>
>                 Key: HIVE-867
>                 URL: https://issues.apache.org/jira/browse/HIVE-867
>             Project: Hadoop Hive
>          Issue Type: New Feature
>            Reporter: Edward Capriolo
>            Assignee: Edward Capriolo
>         Attachments: hive-867-1.diff, hive-867-2.diff, hive-867-3.diff
>
>
> Some UDF's that mysql has that hive does not. 
> atan
> aes_decrypt
> aes_encrypt
> bit_and
> bit_count
> bit_length
> bit_or
> bit_xor
> char_length
> char
> character_length
> collation
> compress
> crc32
> encode
> encrypt
> format
> greatest
> in
> inet_oton
> inet_ntoa
> match
> md5
> oct
> ord
> pi
> radians
> sha1 _sha
> sign
> sleep
> truncate

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message