I need to convert my JAVA program into Native function API.. Can anyone help me with this?

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

#My JAVA Program

import javax.crypto.Cipher;

import javax.crypto.spec.IvParameterSpec;

import javax.crypto.spec.SecretKeySpec;

import org.apache.tomcat.util.codec.binary.Base64;

public class AESencdec {

private static final String key = "aesEncryptionKey";

private static final String initVector = "encryptionIntVec";

public static String encrypt(String value) {

try {

IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));

SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");

Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");

cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);

byte[] encrypted = cipher.doFinal(value.getBytes());

return Base64.encodeBase64String(encrypted);

} catch (Exception ex) {

ex.printStackTrace();

}

return null;

}

}

This is my JAVA program.. I need to convert this into NATIVE API.. Is this possible???

#My Code:(In Native function API)

function Encryption(){

var Cipher = java.import('javax.crypto.Cipher');

var IvParameterSpec = java.import('javax.crypto.spec.IvParameterSpec');

var SecretKeySpec = java.import('javax.crypto.spec.SecretKeySpec');

//alert(java.setStaticFieldValue('javax.crypto.spec.IvParameterSpec', 'initVector', "aesEncryptionKey"));

// java.setStaticFieldValue(IvParameterSpec, 'initVector', "encryptionIntVec);

}

I can't able to proceed further..How to set the static field and proceed further??

Thanks,