Hello developers

I need a favor to know where i am getting wrong. I am doing encryption using TripleDes using Bouncy castle. I use php on server side to decrypt it. I wonder if is there any padding problem. I can not figure it out. The followig is my code for both the sides. I would appreciate your effort.

Key-XiTo74dOO09N48YeUmuvbL0E
Text-"This is a test Text"

Output-+óÚÛÈ?ga test Text

//J2me

public String performEncrypt(String key, String plainText)
{



BlockCipher engine = new DESedeEngine();
BufferedBlockCipher cipher = new PaddedBlockCipher(new CBCBlockCipher(engine));

byte[] keyBytes = key.getBytes();
byte[] input = plainText.getBytes();

cipher.init(true, new KeyParameter(keyBytes));

byte[] cipherText = new byte[cipher.getOutputSize(input.length)];

int outputLen = cipher.processBytes(input, 0, input.length, cipherText, 0);
try
{
cipher.doFinal(cipherText, outputLen);
}
catch (CryptoException ce)
{
System.err.println(ce);
System.exit(1);
}

return new String(Base64.encode(cipherText)).trim();
}//decryptText

//PHP

<?php

$key="XiTo74dOO09N48YeUmuvbL0E";
$encrypted = $_GET['id'];
$iv = mcrypt_create_iv (mcrypt_get_block_size (MCRYPT_TripleDES, MCRYPT_MODE_CBC), MCRYPT_DEV_RANDOM);

// Decrypting
function decrypt($string, $key) {
$dec = "";
$string = trim(base64_decode($string));
global $iv;
$dec = mcrypt_cbc (MCRYPT_TripleDES, $key, $string, MCRYPT_DECRYPT, $iv);
return $dec;
}


$decrypted = decrypt($encrypted, $key);


echo "Decrypted is ".$decrypted ;
?>

Kind Regards