- substr: documentation ( source)
- var_dump: documentation ( source)
- str_ireplace: documentation ( source)
- strrpos: documentation ( source)
- strtolower: documentation ( source)
<?php
$cipher = 'AES-256-CBC';
// $cipher = 'AES-256-CFB8';
$cipher = OPENSSL_CIPHER_AES_256_CBC;
$mode = strtolower(substr($cipher, strrpos($cipher, '-') - strlen($cipher)));
$ivSize = openssl_cipher_iv_length($cipher);
$blockSize = $ivSize > 0
? $ivSize
: openssl_cipher_iv_length(str_ireplace('-' . $mode, '', $cipher));
var_dump($mode);
var_dump($ivSize);
var_dump($blockSize);