Skip to content

Commit

Permalink
Fix issue with 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dzubchik committed Aug 27, 2020
1 parent 43615fa commit ed8d3bd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/Encryptors/AES192Encryptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ public function __construct($key)
{
$this->secretKey = md5($key);
$this->encryptMethod = sprintf('%s-%s', self::METHOD_NAME, self::ENCRYPT_MODE);
$this->initializationVector = openssl_random_pseudo_bytes(
openssl_cipher_iv_length($this->encryptMethod)
);
$length = openssl_cipher_iv_length($this->encryptMethod);

if (0 !== (int)$length) {
$this->initializationVector = openssl_random_pseudo_bytes($length);
}
}

/**
Expand Down
9 changes: 6 additions & 3 deletions src/Encryptors/AES256Encryptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ public function __construct($key)
{
$this->secretKey = md5($key);
$this->encryptMethod = sprintf('%s-%s', self::METHOD_NAME, self::ENCRYPT_MODE);
$this->initializationVector = openssl_random_pseudo_bytes(
openssl_cipher_iv_length($this->encryptMethod)
);
$length = openssl_cipher_iv_length($this->encryptMethod);

if (0 !== (int)$length) {
$this->initializationVector = openssl_random_pseudo_bytes($length);
}

}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/Encryptors/VariableEncryptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ class VariableEncryptor implements EncryptorInterface
public function __construct($key)
{
$this->secretKey = md5($key);
$this->initializationVector = openssl_random_pseudo_bytes(
openssl_cipher_iv_length(self::ENCRYPT_METHOD)
);
$length = openssl_cipher_iv_length(self::ENCRYPT_METHOD);

if (0 !== (int)$length) {
$this->initializationVector = openssl_random_pseudo_bytes($length);
}
}

/**
Expand Down

0 comments on commit ed8d3bd

Please sign in to comment.