config = $config ?? new Config(['modules' => []]); } /** * @param string $tmpPath * @param int $size * @return array */ public function computeHashes(string $tmpPath, int $size): array { $max = (int)$this->config->get('limits.hash_max_filesize', 10 * 1024 * 1024); if (!is_uploaded_file($tmpPath)) return []; if ($size <= 0 || $size > $max) return []; $sha1 = @hash_file('sha1', $tmpPath); $md5 = @hash_file('md5', $tmpPath); $out = []; if (is_string($sha1)) $out['sha1'] = $sha1; if (is_string($md5)) $out['md5'] = $md5; return $out; } }