compute_hash#

astropy.utils.data.compute_hash(localfn)[source]#

Computes the MD5 hash for a file.

The hash for a data file is used for looking up data files in a unique fashion. This is of particular use for tests; a test may require a particular version of a particular file, in which case it can be accessed via hash to get the appropriate version.

Typically, if you wish to write a test that requires a particular data file, you will want to submit that file to the astropy data servers, and use e.g. get_pkg_data_filename('hash/34c33b3eb0d56eb9462003af249eff28'), but with the hash for your file in place of the hash in the example.

Parameters:
localfnstr

The path to the file for which the hash should be generated.

Returns:
hashstr

The hex digest of the cryptographic hash for the contents of the localfn file.