DBIx::Class::DigestColumns - Automatic digest columns
In your DBIx::Class table class:
__PACKAGE__->load_components(qw/DigestColumns ... Core/); __PACKAGE__->digestcolumns( columns => [qw/ password /], algorithm => 'MD5', encoding => 'base64', auto => 1, );
Note: The component needs to be loaded before Core.
Alternatively you could call each method individually
__PACKAGE__->digest_columns(qw/ password /); __PACKAGE__->digest_algorithm('MD5'); __PACKAGE__->digest_encoding('base64'); __PACKAGE__->digest_auto(1);
This DBIx::Class component can be used to automatically insert a message digest of selected columns. By default DigestColumns will use Digest::MD5 to insert a 128-bit hexadecimal message digest of the column value.
The length of the inserted string will be 32 and it will only contain characters from this set: '0'..'9' and 'a'..'f'.
If you would like to use a specific digest module to create your message digest, you can set "digest_algorithm":
__PACKAGE__->digest_algorithm('SHA-1');
__PACKAGE__->digestcolumns( columns => [qw/ password /], algorithm => $algorithm', encoding => $encoding, auto => 1, );
Calls "digest_columns", "digest_algorithm", and "digest_encoding" and "digest_auto" if the corresponding argument is defined.
Takes a list of columns to be convert to a message digest during insert.
__PACKAGE__->digest_columns(qw/ password /);
Takes the name of a digest algorithm to be used to calculate the message digest.
If a suitible digest module could not be loaded an exception will be thrown.
Supported digest algorithms are:
MD5 MD4 MD2 SHA-1 SHA-256 SHA-384 SHA-512 CRC-16 CRC-32 CRC-CCITT HMAC-SHA-1 HMAC-MD5 Whirlpool Adler-32
digest_algorithm defaults to MD5.
MD5
Selects the encoding to use for the message digest.
__PACKAGE__->digest_encoding('base64');
Possilbe encoding schemes are:
binary hex base64
digest_encoding defaults to hex.
hex
__PACKAGE__->digest_auto(1);
Turns on and off automatic digest columns. When on, this feature makes all UPDATEs and INSERTs automatically insert a message digest of selected columns.
The default is for digest_auto is to be on.
The following DBIx::Class::Row methods are extended by this module:-
DBIx::Class, Digest
Tom Kirkpatrick (tkp) <tkp@cpan.org>
You may distribute this code under the same terms as Perl itself.
To install DBIx::Class::DigestColumns, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Class::DigestColumns
CPAN shell
perl -MCPAN -e shell install DBIx::Class::DigestColumns
For more information on module installation, please visit the detailed CPAN module installation guide.