From: Jerome Jutteau Date: Tue, 17 Dec 2019 17:51:29 +0000 (+0100) Subject: [FEATURE] option to randomize file hash X-Git-Tag: 4.2.0~77 X-Git-Url: https://git.p6c8.net/jirafeau.git/commitdiff_plain/c793d074896f3b22e18d7c3ad45a517f5cebaa1c [FEATURE] option to randomize file hash By configuring `file_hash` option to `random`, file deduplication is not effective anymore but file is not hashed. Signed-off-by: Jerome Jutteau --- diff --git a/lib/config.original.php b/lib/config.original.php index 2fe91fd..1591ae8 100644 --- a/lib/config.original.php +++ b/lib/config.original.php @@ -152,7 +152,8 @@ $cfg['proxy_ip'] = array(); * By default, files are hashed through md5 but other methods are available. * Possible values are 'md5' and 'md5_outside'. * With 'md5' option, the whole file is hashed through md5. This is the default. - * With 'md5_outside', md5 is used to hash the first part of the file, the last part of the file + * With 'md5_outside', md5 is used to hash the first part of the file, the last part of the file. + * With 'random', file hash not set to a random value and file deduplication cannot work anymore but it is fast and safe. * and the file's size. This method is fast for large files but cannot be perfect. */ $cfg['file_hash'] = 'md5'; diff --git a/lib/functions.php b/lib/functions.php index 5a5316c..1dd03e5 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -321,7 +321,7 @@ function jirafeau_delete_file($hash) /** hash file's content - * @param $method hash method, see 'file_hash' option. 'md5' or 'md5_outside'. + * @param $method hash method, see 'file_hash' option. Valid methods are 'md5', 'md5_outside' or 'random' * @param $file_path file to hash * @returns hash string */ @@ -332,6 +332,8 @@ function jirafeau_hash_file($method, $file_path) return jirafeau_md5_outside($file_path); case 'md5': return md5_file($file_path); + case 'random': + return jirafeau_gen_random(32); } return md5_file($file_path); }