Skip to content

Commit

Permalink
Merge pull request #19 from nick322/bug/18
Browse files Browse the repository at this point in the history
(#18) Fix password is not accepted
  • Loading branch information
nick322 authored Sep 20, 2023
2 parents 43b9f9c + 6925301 commit 7408046
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 7408046

Please sign in to comment.