Commit cb1f0b93 authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Merge branch 'hotfix/2.6' into 'master'

hotfix/2.6 into master

See merge request !4
parents 40e42a3e f90d711d
......@@ -636,13 +636,20 @@ class digitalSafe
/**
* Calculate hash and verify if its correct
*
* @param string $contents base64 encoded file
* @param object $handler handler
* @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.");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment