Digest::file(3pm) Perl Programmers Reference Guide Digest::file(3pm)

# [NAME](#NAME)

Digest::file - Calculate digests of files

# [SYNOPSIS](#SYNOPSIS)

```
  # Poor mans "md5sum" command
  use Digest::file qw(digest_file_hex);
  for (@ARGV) {
      print digest_file_hex($_, "MD5"), "  $_\n";
  }
```

# [DESCRIPTION](#DESCRIPTION)

This module provide 3 convenience functions to calculate the digest of files. The following functions are provided:

[digest\_file( $file, $algorithm, \[$arg,...\] )](#digest_file%28)

This function will calculate and return the binary digest of the bytes of the given file. The function will croak if it fails to open or read the file.

The $algorithm is a string like "MD2", "MD5", "SHA-1", "SHA-512". Additional arguments are passed to the constructor for the implementation of the given algorithm.

[digest\_file\_hex( $file, $algorithm, \[$arg,...\] )](#digest_file_hex%28)

Same as **digest\_file()**, but return the digest in hex form.

[digest\_file\_base64( $file, $algorithm, \[$arg,...\] )](#digest_file_base64%28)

Same as **digest\_file()**, but return the digest as a base64 encoded string.

# [SEE ALSO](#SEE_ALSO)

Digest

2026-10-27 perl v5.44.0

---

Document: Digest::file(3pm) from perl 5.44.0-r4 (Chainguard OS)
Source: https://github.com/Perl/perl5.git
