Skip to content

Commit

Permalink
(#18) Fix password is not accepted
Browse files Browse the repository at this point in the history
  • Loading branch information
nick322 committed Sep 20, 2023
1 parent 43b9f9c commit 6925301
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@

* Fix for very slow encryption [#10](https://github.com/nick322/secure-spreadsheet/issues/10)
.
Thanks for @jonathanbromley contribution.
Thanks for @jonathanbromley contribution.

## 1.0.9 (2023-09-20)

* Fix password is not accepted [#18](https://github.com/nick322/secure-spreadsheet/issues/18)
11 changes: 10 additions & 1 deletion src/Encrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,16 @@ private function _crypt($encrypt, $cipherAlgorithm, $cipherChaining, $key, $iv,

private function _hash($algorithm, ...$buffers)
{
return unpack('C*', hash(strtolower($algorithm), pack('C*', ...$buffers), true));
$algorithm = strtolower($algorithm);

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

if (!in_array($algorithm, hash_algos())) throw new \Exception("Hash algorithm '$algorithm' not supported!");

$ctx = hash_init($algorithm);

hash_update($ctx, pack('C*', ...$buffers));
return unpack('C*', hash_final($ctx, true));
}

private function _hmac($algorithm, $key, $fileName)
Expand Down

0 comments on commit 6925301

Please sign in to comment.