openssl_cipher_iv_length

Supported Versions: PHP 5 >= 5.3.3, PHP 7, PHP 8
Gets the cipher iv length
openssl_cipher_iv_length(string $cipher_algo): int|false
    public function encrypt($value$serialize true)

    {

        
$iv random_bytes(openssl_cipher_iv_length(strtolower($this->cipher)));



        
$value \openssl_encrypt(

            
$serialize serialize($value) : $value,
    protected function validPayload($payload)

    {

        return 
is_array($payload) && isset($payload['iv'], $payload['value'], $payload['mac']) &&

            
strlen(base64_decode($payload['iv'], true)) === openssl_cipher_iv_length(strtolower($this->cipher));

    }