NAME
Venus::Role::Digestable - Digestable Role
ABSTRACT
Digestable Role for Perl 5
SYNOPSIS
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"
DESCRIPTION
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.
METHODS
This package provides the following methods:
b64digest
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
- b64digest example 1
-
package main; my $example = Example->new(data => 123); my $b64digest = $example->b64digest; # "/PFIeIRxSIuCLPcrbWypwXVUpMY"
- b64digest example 2
-
package main; my $example = Example->new(data => 123); my $b64digest = $example->b64digest('sha-1', 'execute'); # "T+raai5I0suKC3VpiZ8bqt0WXE0"
- b64digest example 3
-
package main; my $example = Example->new(data => 123); my $b64digest = $example->b64digest('sha-1', 'execute', '456'); # "5Vf077AO11mZZfaQknfOtzfhzPc"
bindigest
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.
Since 0.01
- bindigest example 1
-
package main; my $example = Example->new(data => 123); my $bindigest = $example->bindigest; # pack("H*","fcf148788471488b822cf72b6d6ca9c17554a4c6")
- bindigest example 2
-
package main; my $example = Example->new(data => 123); my $bindigest = $example->bindigest('sha-1', 'execute'); # pack("H*","4feada6a2e48d2cb8a0b7569899f1baadd165c4d")
- bindigest example 3
-
package main; my $example = Example->new(data => 123); my $bindigest = $example->bindigest('sha-1', 'execute', '456'); # pack("H*","e557f4efb00ed7599965f6909277ceb737e1ccf7")
digest
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.
Since 0.01
- digest example 1
-
package main; my $example = Example->new(data => 123); my $digest = $example->digest; # "fcf148788471488b822cf72b6d6ca9c17554a4c6"
- digest example 2
-
package main; my $example = Example->new(data => 123); my $digest = $example->digest('sha-1', 'execute'); # "4feada6a2e48d2cb8a0b7569899f1baadd165c4d"
- digest example 3
-
package main; my $example = Example->new(data => 123); my $digest = $example->digest('sha-1', 'execute', '456'); # "e557f4efb00ed7599965f6909277ceb737e1ccf7"
digester
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.
Since 0.01
- digester example 1
-
package main; my $example = Example->new(data => 123); my $digester = $example->digester; # bless(..., "Digest::SHA")
- digester example 2
-
package main; my $example = Example->new(data => 123); my $digester = $example->digester('md5'); # bless(..., "Digest::MD5")
hexdigest
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.
Since 0.01
- hexdigest example 1
-
package main; my $example = Example->new(data => 123); my $hexdigest = $example->hexdigest; # "fcf148788471488b822cf72b6d6ca9c17554a4c6"
- hexdigest example 2
-
package main; my $example = Example->new(data => 123); my $hexdigest = $example->hexdigest('sha-1', 'execute'); # "4feada6a2e48d2cb8a0b7569899f1baadd165c4d"
- hexdigest example 3
-
package main; my $example = Example->new(data => 123); my $hexdigest = $example->hexdigest('sha-1', 'execute', '456'); # "e557f4efb00ed7599965f6909277ceb737e1ccf7"
AUTHORS
Awncorp, awncorp@cpan.org
LICENSE
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.