3v4l.org

run code in 300+ PHP versions simultaneously
<?php $key = 'secret'; $input = 'My secret string!'; $iv = NULL; // MCrypt $handle = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_ECB, ''); // PKCS#7 padding //$bsize = mcrypt_enc_get_block_size($handle); //$pad = $bsize - (strlen($input) % $bsize); //$input .= str_repeat(chr($pad), $pad); // IV //$ivsize = mcrypt_enc_get_iv_size($handle); //$iv = mcrypt_create_iv($ivsize, MCRYPT_DEV_URANDOM); // Encrypt mcrypt_generic_init($handle, $key, $iv); $output = mcrypt_generic($handle, $input); mcrypt_generic_deinit($handle); mcrypt_module_close($handle); echo "MCrypt:\n", // "\tIV: ", bin2hex($iv), " (", $ivsize, " bytes)\n", "\tInput: ", bin2hex($input), "\n", "\tOutput: ", bin2hex($output), "\n\n"; //$output = $iv.$output; // OpenSSL // IV //$ivsize = openssl_cipher_iv_length('bf-ecb'); //$iv = substr($output, 0, $ivsize); //$output = substr($output, $ivsize); $input = openssl_decrypt($output, 'bf-ecb', $key, OPENSSL_RAW_DATA, $iv); echo "OpenSSL:\n", // "\tIV: ", bin2hex($iv), " (", $ivsize, " bytes)\n", "\tOutput: ", bin2hex($output), "\n", "\tInput: ", bin2hex($input), "\n\n"; empty($input) && var_dump(openssl_error_string());

preferences:
38.19 ms | 402 KiB | 5 Q