Laravel 5.7: openssl_cipher_iv_length(): Unknown cipher algorithm
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am developing an app in Laravel Framework 5.7.13.
I have a class called
<?php
namespace AppLibrary;
class Crypto
private $cipher;
private $cstrong;
private $keylen;
private $key;
public function __Crypto()
$this->cipher= Config::get('cipher');
$this->cstrong = true;
$this->keylen = 5;
$this->key = bin2hex(openssl_random_pseudo_bytes($keylen, $cstrong));
public function opensslEncrypt($value)
$ivlen = openssl_cipher_iv_length($this->cipher);
$iv = openssl_random_pseudo_bytes($ivlen);
$ciphertext_raw = openssl_encrypt($value, $this->cipher, $this->key, $options=OPENSSL_RAW_DATA, $iv);
$hmac = hash_hmac('sha256', $ciphertext_raw, $this->key, $as_binary=true);
$ciphertext = base64_encode( $iv.$hmac.$ciphertext_raw );
return $ciphertext ;
Now in my controller I did:
$crypto = new Crypto();
$encryptedValue = $crypto->opensslEncrypt($orderId);
In my Configapp.php
'cipher' => 'AES-256-CBC'
But when I run my app, I get
ErrorException (E_WARNING)
openssl_cipher_iv_length(): Unknown cipher algorithm
How to resolve this?
I tried to comment the cipher line in the Configapp.php, but then it gave some other errors.
Please help...
encryption laravel-5.7
add a comment |
I am developing an app in Laravel Framework 5.7.13.
I have a class called
<?php
namespace AppLibrary;
class Crypto
private $cipher;
private $cstrong;
private $keylen;
private $key;
public function __Crypto()
$this->cipher= Config::get('cipher');
$this->cstrong = true;
$this->keylen = 5;
$this->key = bin2hex(openssl_random_pseudo_bytes($keylen, $cstrong));
public function opensslEncrypt($value)
$ivlen = openssl_cipher_iv_length($this->cipher);
$iv = openssl_random_pseudo_bytes($ivlen);
$ciphertext_raw = openssl_encrypt($value, $this->cipher, $this->key, $options=OPENSSL_RAW_DATA, $iv);
$hmac = hash_hmac('sha256', $ciphertext_raw, $this->key, $as_binary=true);
$ciphertext = base64_encode( $iv.$hmac.$ciphertext_raw );
return $ciphertext ;
Now in my controller I did:
$crypto = new Crypto();
$encryptedValue = $crypto->opensslEncrypt($orderId);
In my Configapp.php
'cipher' => 'AES-256-CBC'
But when I run my app, I get
ErrorException (E_WARNING)
openssl_cipher_iv_length(): Unknown cipher algorithm
How to resolve this?
I tried to comment the cipher line in the Configapp.php, but then it gave some other errors.
Please help...
encryption laravel-5.7
add a comment |
I am developing an app in Laravel Framework 5.7.13.
I have a class called
<?php
namespace AppLibrary;
class Crypto
private $cipher;
private $cstrong;
private $keylen;
private $key;
public function __Crypto()
$this->cipher= Config::get('cipher');
$this->cstrong = true;
$this->keylen = 5;
$this->key = bin2hex(openssl_random_pseudo_bytes($keylen, $cstrong));
public function opensslEncrypt($value)
$ivlen = openssl_cipher_iv_length($this->cipher);
$iv = openssl_random_pseudo_bytes($ivlen);
$ciphertext_raw = openssl_encrypt($value, $this->cipher, $this->key, $options=OPENSSL_RAW_DATA, $iv);
$hmac = hash_hmac('sha256', $ciphertext_raw, $this->key, $as_binary=true);
$ciphertext = base64_encode( $iv.$hmac.$ciphertext_raw );
return $ciphertext ;
Now in my controller I did:
$crypto = new Crypto();
$encryptedValue = $crypto->opensslEncrypt($orderId);
In my Configapp.php
'cipher' => 'AES-256-CBC'
But when I run my app, I get
ErrorException (E_WARNING)
openssl_cipher_iv_length(): Unknown cipher algorithm
How to resolve this?
I tried to comment the cipher line in the Configapp.php, but then it gave some other errors.
Please help...
encryption laravel-5.7
I am developing an app in Laravel Framework 5.7.13.
I have a class called
<?php
namespace AppLibrary;
class Crypto
private $cipher;
private $cstrong;
private $keylen;
private $key;
public function __Crypto()
$this->cipher= Config::get('cipher');
$this->cstrong = true;
$this->keylen = 5;
$this->key = bin2hex(openssl_random_pseudo_bytes($keylen, $cstrong));
public function opensslEncrypt($value)
$ivlen = openssl_cipher_iv_length($this->cipher);
$iv = openssl_random_pseudo_bytes($ivlen);
$ciphertext_raw = openssl_encrypt($value, $this->cipher, $this->key, $options=OPENSSL_RAW_DATA, $iv);
$hmac = hash_hmac('sha256', $ciphertext_raw, $this->key, $as_binary=true);
$ciphertext = base64_encode( $iv.$hmac.$ciphertext_raw );
return $ciphertext ;
Now in my controller I did:
$crypto = new Crypto();
$encryptedValue = $crypto->opensslEncrypt($orderId);
In my Configapp.php
'cipher' => 'AES-256-CBC'
But when I run my app, I get
ErrorException (E_WARNING)
openssl_cipher_iv_length(): Unknown cipher algorithm
How to resolve this?
I tried to comment the cipher line in the Configapp.php, but then it gave some other errors.
Please help...
encryption laravel-5.7
encryption laravel-5.7
asked Nov 15 '18 at 16:24
ChaitallyChaitally
155
155
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I ran into a similar problem with Laravel 5.7.13.
My error with Laravel and the openssl_cipher_iv_length() function was encountered when I updated my WampServer installation to PHP v7.2.x (from v7.1.10). Yes, I am running on Windows.
Switching back to php v7.1.10 would clear the error.
To solve my error with openssl_cipher_iv_length(), I compared the php.ini files from the two php versions. When comparing the files I noticed that I did not have the extension_dir set properly. This was my main issue, but there were other edits I made in the past that I also incorporated into the new PHP environment (i.e. extensions that were enabled and XDEBUG settings).
Also... I did notice that the extension names were previously defined as:
extension=php_<ext>.dll
or
extension=<ext>.so
and are now using:
extension=<ext>
So my issue with openssl_cipher_iv_length() was a result of the PHP version and not Laravel.
I hope this information helps.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323795%2flaravel-5-7-openssl-cipher-iv-length-unknown-cipher-algorithm%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I ran into a similar problem with Laravel 5.7.13.
My error with Laravel and the openssl_cipher_iv_length() function was encountered when I updated my WampServer installation to PHP v7.2.x (from v7.1.10). Yes, I am running on Windows.
Switching back to php v7.1.10 would clear the error.
To solve my error with openssl_cipher_iv_length(), I compared the php.ini files from the two php versions. When comparing the files I noticed that I did not have the extension_dir set properly. This was my main issue, but there were other edits I made in the past that I also incorporated into the new PHP environment (i.e. extensions that were enabled and XDEBUG settings).
Also... I did notice that the extension names were previously defined as:
extension=php_<ext>.dll
or
extension=<ext>.so
and are now using:
extension=<ext>
So my issue with openssl_cipher_iv_length() was a result of the PHP version and not Laravel.
I hope this information helps.
add a comment |
I ran into a similar problem with Laravel 5.7.13.
My error with Laravel and the openssl_cipher_iv_length() function was encountered when I updated my WampServer installation to PHP v7.2.x (from v7.1.10). Yes, I am running on Windows.
Switching back to php v7.1.10 would clear the error.
To solve my error with openssl_cipher_iv_length(), I compared the php.ini files from the two php versions. When comparing the files I noticed that I did not have the extension_dir set properly. This was my main issue, but there were other edits I made in the past that I also incorporated into the new PHP environment (i.e. extensions that were enabled and XDEBUG settings).
Also... I did notice that the extension names were previously defined as:
extension=php_<ext>.dll
or
extension=<ext>.so
and are now using:
extension=<ext>
So my issue with openssl_cipher_iv_length() was a result of the PHP version and not Laravel.
I hope this information helps.
add a comment |
I ran into a similar problem with Laravel 5.7.13.
My error with Laravel and the openssl_cipher_iv_length() function was encountered when I updated my WampServer installation to PHP v7.2.x (from v7.1.10). Yes, I am running on Windows.
Switching back to php v7.1.10 would clear the error.
To solve my error with openssl_cipher_iv_length(), I compared the php.ini files from the two php versions. When comparing the files I noticed that I did not have the extension_dir set properly. This was my main issue, but there were other edits I made in the past that I also incorporated into the new PHP environment (i.e. extensions that were enabled and XDEBUG settings).
Also... I did notice that the extension names were previously defined as:
extension=php_<ext>.dll
or
extension=<ext>.so
and are now using:
extension=<ext>
So my issue with openssl_cipher_iv_length() was a result of the PHP version and not Laravel.
I hope this information helps.
I ran into a similar problem with Laravel 5.7.13.
My error with Laravel and the openssl_cipher_iv_length() function was encountered when I updated my WampServer installation to PHP v7.2.x (from v7.1.10). Yes, I am running on Windows.
Switching back to php v7.1.10 would clear the error.
To solve my error with openssl_cipher_iv_length(), I compared the php.ini files from the two php versions. When comparing the files I noticed that I did not have the extension_dir set properly. This was my main issue, but there were other edits I made in the past that I also incorporated into the new PHP environment (i.e. extensions that were enabled and XDEBUG settings).
Also... I did notice that the extension names were previously defined as:
extension=php_<ext>.dll
or
extension=<ext>.so
and are now using:
extension=<ext>
So my issue with openssl_cipher_iv_length() was a result of the PHP version and not Laravel.
I hope this information helps.
answered Jan 3 at 16:38
AndrewFAndrewF
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323795%2flaravel-5-7-openssl-cipher-iv-length-unknown-cipher-algorithm%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown