File hash

Hashes of uploaded files, which can be found on a variety of sites from archive.org to wikileaks.org, allow files to be uniquely identified, duplicate files to be detected, and copies to be verified against the original source.

File Hash module generates and stores BLAKE2b-128, BLAKE2b-160, BLAKE2b-224, BLAKE2b-256, BLAKE2b-384, BLAKE2b-512, MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512/224, SHA-512/256, SHA-512, SHA3-224, SHA3-256, SHA3-384 and/or SHA3-512 hashes for each file uploaded to the site (note that usage of the BLAKE2b hash algorithm requires the Sodium PHP extension or paragonie/sodium_compat polyfill).

Hash algorithms can be enabled and disabled by the site administrator.

Hash values are loaded into the File object (as fields in the 2.x and 3.x branches) where they are available to the theme, Views and other modules.

Tokens are provided for the full hashes, as well as pairtree tokens useful for content-addressable storage. For example, if the MD5 hash for a file is 3998b02c5cd2723153c39701683a503b, you could store it in the files/39/98 directory using these tokens: [file:filehash-md5-pair-1]/[file:filehash-md5-pair-2]. Note, to use these tokens to configure the file upload directory, File (Field) Paths module or File Entity Paths module is required.

Optional duplicate file prevention

A checkbox in file hash settings allows duplicate uploaded files to be rejected. This feature should be considered a proof-of-concept—you may want better UX for such a feature. Note, if you use a module that allows existing file entities to be updated with a new file, the duplicate check will not be performed on the contents of the updated file (please file a feature request if this issue affects you). In Drupal 7, empty files are not considered duplicate files, as such "files" may represent remote media assets, etc.

You can support development by contributing or sponsoring.

Ports:

This project has been ported to Backdrop CMS.

Supporting organizations: 

Project information

Releases