How to implement the encrypt and decrypt methods
The code in Listing 2-2 implements AES 128-bit encryption. Test the encryption and decryption code in Eclipse. The Activator class, created by Eclipse, must exist in the plug-in.
Listing 2-2  
package com.example.myencryptionextension;
 
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import com.actuate.ais.encryption.IEncryptionProvider;
 
public class EncryptionProvider implements IEncryptionProvider {
 
  private final byte[] key = {-0x6A, 0x6D, 0x49, -0x05, 0x79, 0x38, 0x48, -0x0C, 0x6A, 0x19, 0x46, 0x1E, -0x09, -0x5E, -0x2F, 0x17};
 
  private Cipher getCipher(int mode) {
    Cipher cipher = null;
    SecretKeySpec keyspec = new SecretKeySpec(key, "AES");
    try {
      cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
      cipher.init(mode, keyspec);
    } catch (Exception ex) {}
    return cipher;
  }
 
  @Override
  public String decrypt(String encryptedString) {
 
    String decryptedString = null;
 
    try {
      if (encryptedString == null) return null;
      if ("".equals(encryptedString)) return "";
 
      byte[] encryptedBytes = new BASE64Decoder().decodeBuffer(encryptedString);
      Cipher cipher = getCipher(Cipher.DECRYPT_MODE);
      byte[] raw = cipher.doFinal(encryptedBytes);
      decryptedString = new String(raw);
    } catch (Exception ex) {}
 
    return decryptedString;
  }
 
  @Override
  public String encrypt(String plainText) {
 
    String encryptedString = null;
 
    try {
      if (plainText == null) return null;
      if ("".equals(plainText)) return "";
 
      Cipher cipher = getCipher(Cipher.ENCRYPT_MODE);
      byte[] raw = cipher.doFinal(plainText.getBytes());
      encryptedString = new BASE64Encoder().encode(raw);
 
    } catch (Exception ex) {}
 
    return encryptedString;
  }
 
}

Additional Links:

Copyright Actuate Corporation 2012