Mojo::File::Role::Digest - A role for Mojo::File to calculate digests
# single file use Mojo::File 'path'; my $file = path($path)->with_roles('+Digest'); # modified file class use Mojo::File; my $class = Mojo::File->with_roles('+Digest'); my $file = $class->new($path); $file->md5_sum; $file->quickxor_hash; # requires Digest::QuickXor $file->sha1_sum; $file->sha256_sum;
Mojo::File::Role::Digest is a role for Mojo::File to calculate MD5, SHA1, SHA256, and QuickXor digests.
If the path isn't an existing file, all methods return an empty string ''.
''
use Mojo::File 'path'; my $file = path($path); my $file_with_digest = $file->with_roles('+Digest');
Apply to a single Mojo::File object. See "with_roles" in Mojo::Base.
use Mojo::File; my $class = Mojo::File->with_roles('+Digest'); my $file1 = $class->new($path1); my $file2 = $class->new($path2);
Create a modified file class with applied digest role.
$string = $file->md5_sum;
Returns the MD5 sum of the file in hexadecimal form. See "hexdigest" in Digest::MD5.
$string = $file->quickxor_hash;
Returns the base64 encoded QuickXorHash of the file. See "b64digest" in Digest::QuickXor. Requires Digest::QuickXor 0.03 or higher.
$string = $file->sha1_sum;
Returns the SHA1 sum of the file in hexadecimal form. See "hexdigest" in Digest::SHA.
$string = $file->sha256_sum;
Returns the SHA256 sum of the file in hexadecimal form. See "hexdigest" in Digest::SHA.
© 2019–2020 by Tekki (Rolf Stöckli).
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Mojo::File, Mojo::Base, Role::Tiny, Digest::MD5, Digest::QuickXor, Digest::SHA.
To install Mojo::File::Role::Digest, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::File::Role::Digest
CPAN shell
perl -MCPAN -e shell install Mojo::File::Role::Digest
For more information on module installation, please visit the detailed CPAN module installation guide.