如何通过转换PHP代码来加密Java中的文本?

On server (PHP code), we have 2 methods to encrypt/decrypt facebook id like this:

private function encryptFacebookId($text)
{
        $method = "AES-256-CBC";
        $iv_size = mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CBC);
        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);

        $encrypted = openssl_encrypt($text, $method, $this->_cryptKey, 0, $iv);

        return base64_encode($iv . $encrypted);
}

public function decryptFacebookId($text)
{
        $text = base64_decode($text);
        $method = "AES-256-CBC";
        $iv_size = mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CBC);
        $iv = substr($text, 0, $iv_size);

        $decrypted = openssl_decrypt(substr($text, $iv_size), $method, $this->_cryptKey, 0, $iv);

        return $decrypted;
}

with _cryptKey="1231238912389123asdasdklasdkjasd";

It's OK with the same value of input and output at server. But When I'm connecting to server as client (Android/Java) by HTTP request (REST). I try to convert method of PHP code to Java code at method "encryptFacebookId($text)" and send encryption text to server but the result of method decryptFacebookId($text) at server is not same value with the client.

This is my code at client

String facebookId = "123456789";
        String keyCrypt = "1231238912389123asdasdklasdkjasd";

        try {
            SecretKeySpec skeySpec = new SecretKeySpec(keyCrypt.getBytes(),
                    "AES");
            Cipher enCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
            byte[] ivData = new byte[enCipher.getBlockSize()];
            IvParameterSpec iv = new IvParameterSpec(ivData);
            enCipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);

            byte[] encryptedBytes = enCipher.doFinal(facebookId.getBytes());

            String ivEncrypted = new String(ivData)
                    + new String(encryptedBytes);

            String strEncode = Base64
                    .encodeBase64String(ivEncrypted.getBytes());

            System.out.println(strEncode);

        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

Please help me to find the right way.

1) If you want to concat binary byte[] don't transform it to String use for example:

public static byte[] concat(byte[]... args) 
{
    int fulllength = 0;
    for (byte[] arrItem : args) {
        fulllength += arrItem.length;
    }
    byte[] outArray = new byte[fulllength];
    int start = 0;
    for (byte[] arrItem : args) {
        System.arraycopy(arrItem, 0, outArray, start, arrItem.length);
        start += arrItem.length;
    }
    return outArray;
}

byte[] ivEncrypted = concat(ivData, encryptedBytes);

2) You have to be sure that the Base64 encoders are compatible.