Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Maarch
digitalSafe
Commits
cb1f0b93
Commit
cb1f0b93
authored
Mar 04, 2020
by
Alexandre Morin
Browse files
Merge branch 'hotfix/2.6' into 'master'
hotfix/2.6 into master See merge request
!4
parents
40e42a3e
f90d711d
Changes
1
Hide whitespace changes
Inline
Side-by-side
bundle/digitalSafe/Controller/digitalSafe.php
View file @
cb1f0b93
...
...
@@ -636,13 +636,20 @@ class digitalSafe
/**
* Calculate hash and verify if its correct
*
* @param
string $contents base64 encoded fi
le
* @param
object $handler hand
le
r
* @param string $hash hash file
* @param string $hashAlgorithm hash algortithm used to crypt file
*/
protected
function
checkHash
(
$
contents
,
$hash
,
$hashAlgorithm
)
protected
function
checkHash
(
$
handler
,
$hash
,
$hashAlgorithm
)
{
$hash_calculated
=
strtolower
(
hash
(
$hashAlgorithm
,
base64_decode
(
$contents
)));
if
(
is_string
(
$handler
))
{
$hash_calculated
=
strtolower
(
hash
(
$hashAlgorithm
,
base64_decode
(
$handler
)));
}
else
{
file_put_contents
(
\
laabs
::
getTmpDir
()
.
DIRECTORY_SEPARATOR
.
$hash
,
base64_decode
(
stream_get_contents
(
$handler
)));
rewind
(
$handler
);
$hash_calculated
=
strtolower
(
hash
(
$hashAlgorithm
,
file_get_contents
(
\
laabs
::
getTmpDir
()
.
DIRECTORY_SEPARATOR
.
$hash
)));
unlink
(
\
laabs
::
getTmpDir
()
.
DIRECTORY_SEPARATOR
.
$hash
);
}
if
(
$hash_calculated
!==
strtolower
(
$hash
))
{
throw
\
laabs
::
newException
(
"digitalResource/invalidHashException"
,
"Invalid hash."
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment