addfilebin#

Feed the raw byte contents of a filehandle into a Digest::SHA object.

The binary-mode backend behind addfile. Reads until end of file with no newline translation and no character interpretation - exactly what you want when hashing a file whose bytes must be preserved literally (archives, images, compiled artefacts).

Normally you use addfile with an explicit "b" mode; _addfilebin is the leading-underscore XS hook, exposed here for completeness.

Σύνοψη#

open my $fh, "<:raw", "archive.tar.gz" or die $!;
$sha->_addfilebin($fh);

Τι επιστρέφεται#

The receiver, for chaining.

Παραδείγματα#

open my $fh, "<:raw", "data.bin" or die $!;
my $sha = Digest::SHA->new(256);
$sha->_addfilebin($fh);
print $sha->hexdigest;
my $sha = Digest::SHA->new(512);
$sha->_addfilebin("path/to/file");   # also accepts filenames

Οριακές περιπτώσεις#

  • A bad filehandle or unreadable filename croaks with Bad filehandle: ....

  • An empty file leaves the hash state untouched.

  • Called on a non-Digest::SHA object, returns undef.

Διαφορές από το upstream#

Fully compatible with upstream Digest::SHA 6.04.

Δείτε επίσης#

  • addfile - the public, mode-switching wrapper; prefer it in new code.

  • _addfileuniv - universal-newline counterpart.

  • add - string-oriented input for data already in memory.