title: Laravel 5.7: openssl_cipher_iv_length(): Unknown cipher algorithm
body: <p>I am developing an app in Laravel Framework 5.7.13.</p>
  
  <p>I have a class called</p>
  
  <pre><code>&lt;?php
  namespace App\Library;
  
  class Crypto{
  
  private $cipher;
  private $cstrong;
  private $keylen;
  private $key;
  
  
  public function __Crypto(){
      $this-&gt;cipher= Config::get('cipher');
      $this-&gt;cstrong = true;
      $this-&gt;keylen = 5;
      $this-&gt;key = bin2hex(openssl_random_pseudo_bytes($keylen, $cstrong));
  }
  
  public function opensslEncrypt($value){
  
  
      $ivlen = openssl_cipher_iv_length($this-&gt;cipher);
      $iv = openssl_random_pseudo_bytes($ivlen);
      $ciphertext_raw = openssl_encrypt($value, $this-&gt;cipher, $this-&gt;key, $options=OPENSSL_RAW_DATA, $iv);
      $hmac = hash_hmac('sha256', $ciphertext_raw, $this-&gt;key, $as_binary=true);
      $ciphertext = base64_encode( $iv.$hmac.$ciphertext_raw );
  
      return $ciphertext ;
  
  }
  }
  </code></pre>
  
  <p>Now in my controller I did:</p>
  
  <pre><code>$crypto = new Crypto();
  $encryptedValue = $crypto-&gt;opensslEncrypt($orderId);
  </code></pre>
  
  <p>In my Config\app.php</p>
  
  <pre><code>'cipher' =&gt; 'AES-256-CBC'
  </code></pre>
  
  <p>But when I run my app, I get</p>
  
  <p>ErrorException (E_WARNING)
  openssl_cipher_iv_length(): Unknown cipher algorithm</p>
  
  <p>How to resolve this?</p>
  
  <p>I tried to comment the cipher line in the Config\app.php, but then it gave some other errors.</p>
  
  <p>Please help...</p>