Skip to content

Commit

Permalink
fix: buffer (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddevsr authored Sep 3, 2024
1 parent 3ee684c commit 7362d91
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Secure.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,7 @@ private function _crypt($encrypt, $cipherAlgorithm, $cipherChaining, $key, $iv,
private function _hash($algorithm, ...$buffers)
{
$algorithm = strtolower($algorithm);

$buffers = [...$buffers];
$buffers = array_merge([], ...$buffers);

if (! in_array($algorithm, hash_algos(), true)) {
throw new Exception("Hash algorithm '{$algorithm}' not supported!"); // @codeCoverageIgnore
Expand Down Expand Up @@ -506,10 +505,11 @@ private function _convertPasswordToKey($password, $hashAlgorithm, $saltValue, $s
$key = $this->_hash($hashAlgorithm, $key, $blockKey);

// Truncate or pad as needed to get to length of keyBits
$keyBytes = $keyBits / 8;
if (count($key) < $keyBytes) {
$keyBytes = $keyBits / 8;
$keyCounter = count($key);
if ($keyCounter < $keyBytes) {
$key = array_pad($key, $keyBytes, 0x36);
} elseif (count($key) > $keyBytes) {
} elseif ($keyCounter > $keyBytes) {
$key = array_slice($key, 0, $keyBytes);
}

Expand Down

0 comments on commit 7362d91

Please sign in to comment.