/** * Gets the hash of a file. * * You can use this to compare if you got two times the same file uploaded. * * @param string $file Path to the file on your local machine. * @param string $method 'md5' or 'sha1' * @throws \InvalidArgumentException * @link http://php.net/manual/en/function.md5-file.php * @link http://php.net/manual/en/function.sha1-file.php * @link http://php.net/manual/en/function.sha1-file.php#104748 * @return string */ public static function getFileHash($file, $method = 'sha1') { return StorageUtils::getFileHash($file, $method); }
/** * testGetFileHashInvalidArgumentException * * @expectedException \InvalidArgumentException */ public function testGetFileHashInvalidArgumentException() { StorageUtils::getFileHash($this->fileFixtures . 'titus.jpg', 'invalid-hash-method!'); }
/** * Calculates the hash of a file. * * You can use this to compare if you got two times the same file uploaded. * * @param string $file Path to the file on your local machine. * @param string $method 'md5' or 'sha1' * @throws \InvalidArgumentException * @link http://php.net/manual/en/function.md5-file.php * @link http://php.net/manual/en/function.sha1-file.php * @link http://php.net/manual/en/function.sha1-file.php#104748 * @return string */ public function calculateFileHash($file, $method = 'sha1') { return StorageUtils::getFileHash($file, $method); }