Venus::Role::Digestable - Digestable Role
Digestable Role for Perl 5
package Example; use Venus::Class; attr 'data'; with 'Venus::Role::Dumpable'; with 'Venus::Role::Digestable'; sub execute { my ($self, @args) = @_; return [$self->data, @args]; } package main; my $example = Example->new(data => 123); # $example->digest; # "a6c3d9ae59f31690eddbdd15271e856a6b6f15d5"
This package modifies the consuming package and provides methods for producing message digests from a dump of the object or the return value of a dispatched method call. All algorithms supported by Digest are supported, e.g. SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, HMAC-MD5, HMAC-SHA-1, etc.
SHA-1
SHA-224
SHA-256
SHA-384
SHA-512
HMAC-MD5
HMAC-SHA-1
This package provides the following methods:
b64digest(string $algo, string $method, any @args) (string)
The b64digest method returns a base64 formatted digest of the object or return value of a dispatched method call. The algorithm defaults to SHA-1. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.
Since 0.01
0.01
package main; my $example = Example->new(data => 123); my $b64digest = $example->b64digest; # "/PFIeIRxSIuCLPcrbWypwXVUpMY"
package main; my $example = Example->new(data => 123); my $b64digest = $example->b64digest('sha-1', 'execute'); # "T+raai5I0suKC3VpiZ8bqt0WXE0"
package main; my $example = Example->new(data => 123); my $b64digest = $example->b64digest('sha-1', 'execute', '456'); # "5Vf077AO11mZZfaQknfOtzfhzPc"
bindigest(string $algo, string $method, any @args) (string)
The bindigest method returns a binary formatted digest of the object or return value of a dispatched method call. The algorithm defaults to SHA-1. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.
package main; my $example = Example->new(data => 123); my $bindigest = $example->bindigest; # pack("H*","fcf148788471488b822cf72b6d6ca9c17554a4c6")
package main; my $example = Example->new(data => 123); my $bindigest = $example->bindigest('sha-1', 'execute'); # pack("H*","4feada6a2e48d2cb8a0b7569899f1baadd165c4d")
package main; my $example = Example->new(data => 123); my $bindigest = $example->bindigest('sha-1', 'execute', '456'); # pack("H*","e557f4efb00ed7599965f6909277ceb737e1ccf7")
digest(string $algo, string $method, any @args) (string)
The digest method returns a hexadecimal formatted digest of a dump of the object or return value of a dispatched method call. The algorithm defaults to SHA-1. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.
package main; my $example = Example->new(data => 123); my $digest = $example->digest; # "fcf148788471488b822cf72b6d6ca9c17554a4c6"
package main; my $example = Example->new(data => 123); my $digest = $example->digest('sha-1', 'execute'); # "4feada6a2e48d2cb8a0b7569899f1baadd165c4d"
package main; my $example = Example->new(data => 123); my $digest = $example->digest('sha-1', 'execute', '456'); # "e557f4efb00ed7599965f6909277ceb737e1ccf7"
digester(string $algo, string $method, any @args) (string)
The digester method returns a Digest object with a dump of the object or return value of a dispatched method call as the message. The algorithm defaults to SHA-1. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.
package main; my $example = Example->new(data => 123); my $digester = $example->digester; # bless(..., "Digest::SHA")
package main; my $example = Example->new(data => 123); my $digester = $example->digester('md5'); # bless(..., "Digest::MD5")
hexdigest(string $algo, string $method, any @args) (string)
The hexdigest method returns a ... formatted digest of the object or return value of a dispatched method call. The algorithm defaults to SHA-1. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.
package main; my $example = Example->new(data => 123); my $hexdigest = $example->hexdigest; # "fcf148788471488b822cf72b6d6ca9c17554a4c6"
package main; my $example = Example->new(data => 123); my $hexdigest = $example->hexdigest('sha-1', 'execute'); # "4feada6a2e48d2cb8a0b7569899f1baadd165c4d"
package main; my $example = Example->new(data => 123); my $hexdigest = $example->hexdigest('sha-1', 'execute', '456'); # "e557f4efb00ed7599965f6909277ceb737e1ccf7"
Awncorp, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2022, Awncorp, awncorp@cpan.org.
This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.
To install Venus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Venus
CPAN shell
perl -MCPAN -e shell install Venus
For more information on module installation, please visit the detailed CPAN module installation guide.