This seems to work fine in IE8, but whenever I view it in FF3, There is some weird trailing characters after the decrypted text. $decryption_key = "Yru8S09edICE"; $cipher_alg=MCRYPT_RIJNDAEL_256; function hex2bin($data) { $len = strlen($data); return pack("H" . $len, $data); } $iv = bin2hex(mcrypt_create_iv(mcrypt_get_iv_size($cipher_alg, MCRYPT_MODE_CBC), MCRYPT_RAND)); $encryppted_text = mcrypt_encrypt($cipher_alg, $decryption_key, 'this is text', MCRYPT_MODE_CBC, hex2bin($iv)); print $encryppted_text."<br />"; $decrypted_text = mcrypt_decrypt($cipher_alg, $decryption_key, $encryppted_text, MCRYPT_MODE_CBC, hex2bin($iv)); print $decrypted_text; PHP: