*/
public static byte[] decryptString(byte[] source, byte[] mykey, byte[] i_iv) {
byte[] out = null;
try {
IPad padding = PadFactory.getInstance("PKCS7");
padding.init(16);
IMode mode = ModeFactory.getInstance("CBC", "AES", 16);
Map attributes = new HashMap();
byte[] iv = i_iv;
byte[] ct = new byte[source.length];
byte[] key = mykey;
attributes.put(IMode.KEY_MATERIAL, key);
attributes.put(IMode.CIPHER_BLOCK_SIZE, new Integer(16));
attributes.put(IMode.IV, iv);
attributes.put(IMode.STATE, new Integer(IMode.DECRYPTION));
mode.init(attributes);
for (int i = 0; i + 16 <= source.length; i += 16) {
mode.update(source, i, ct, i);
}
try {
int unpad = padding.unpad(ct, 0, ct.length);
out = new byte[ct.length - unpad];
System.arraycopy(ct, 0, out, 0, out.length);
} catch (Exception e) {
out = new byte[ct.length];
System.arraycopy(ct, 0, out, 0, out.length);