md5()

audeer.md5(path, chunk_size=8192)[source]

Calculate MD5 checksum of file or folder.

If path is a folder, the checksum is calculated from all files in the folder (including hidden files). The checksum also encodes the (relative) file names, so that renaming files results in a different checksum. However, the calculation is independent of file separator of the operation systems. Empty folders are ignored.

Parameters
  • path (str) – path to file or folder

  • chunk_size (int) – chunk size in number of bytes

Return type

str

Returns

checksum

Raises

FileNotFoundError – if path does not exist

Examples

>>> path = touch("file.txt")
>>> md5(path)
'd41d8cd98f00b204e9800998ecf8427e'
>>> md5(".")
'3d8e577bddb17db339eae0b3d9bcf180'