Я занимаюсь разработкой приложения в Laravel Framework 5.7.13.
У меня есть класс с именем
<?php
namespace App\Library;
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 ;
}
}
Теперь в моем контроллере я сделал:
$crypto = new Crypto();
$encryptedValue = $crypto->opensslEncrypt($orderId);
В моем Config \ app.php
'cipher' => 'AES-256-CBC'
Но когда я запускаю свое приложение, я получаю
ErrorException (E_WARNING) openssl_cipher_iv_length (): неизвестный алгоритм шифрования
Какчтобы решить эту проблему?
Я пытался закомментировать строку шифра в Config \ app.php, но затем он выдал некоторые другие ошибки.
Пожалуйста, помогите ...