Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dbix::class::encodedcolumn::digest(3pm) [debian man page]

DBIx::Class::EncodedColumn::Digest(3pm) 		User Contributed Perl Documentation		   DBIx::Class::EncodedColumn::Digest(3pm)

NAME
DBIx::Class::EncodedColumn::Digest - Digest backend SYNOPSYS
#SHA-1 / hex encoding / generate check method __PACKAGE__->add_columns( 'password' => { data_type => 'CHAR', size => 40 + 10, encode_column => 1, encode_class => 'Digest', encode_args => {algorithm => 'SHA-1', format => 'hex', salt_length => 10}, encode_check_method => 'check_password', } #SHA-256 / base64 encoding / generate check method __PACKAGE__->add_columns( 'password' => { data_type => 'CHAR', size => 40, encode_column => 1, encode_class => 'Digest', encode_check_method => 'check_password', #no encode_args necessary because these are the defaults ... } DESCRIPTION
ACCEPTED ARGUMENTS
format The encoding to use for the digest. Valid values are 'binary', 'hex', and 'base64'. Will default to 'base64' if not specified. algorithm The digest algorithm to use for the digest. You may specify any valid Digest algorithm. Examples are MD5, SHA-1, Whirlpool etc. Will default to 'SHA-256' if not specified. See Digest for supported digest algorithms. salt_length If you would like to use randomly generated salts to encode values make sure this option is set to > 0. Salts will be automatically generated at encode time and will be appended to the end of the digest. Please make sure that you remember to make sure that to expand the size of your db column to have enough space to store both the digest AND the salt. Please see list below for common digest lengths. METHODS
make_encode_sub $column_name, \%encode_args Returns a coderef that takes two arguments, a plaintext value and an optional salt and returns the encoded value with the salt appended to the end of the digest. If a salt is not provided and the salt_length option was greater than zero it will be randomly generated. make_check_sub $column_name, \%encode_args Returns a coderef that takes the row object and a plaintext value and will return a boolean if the plaintext matches the encoded value. This is typically used for password authentication. COMMON DIGEST LENGTHS
CIPHER | Binary | Base64 | Hex --------------------------------------- | MD2 | 16 | 22 | 32 | | MD4 | 16 | 22 | 32 | | MD5 | 16 | 22 | 32 | | SHA-1 | 20 | 27 | 40 | | SHA-256 | 32 | 43 | 64 | | SHA-384 | 48 | 64 | 96 | | SHA-512 | 64 | 86 | 128 | | CRC-CCITT | 3 | 2 | 3 | | CRC-16 | 5 | 6 | 4 | | CRC-32 | 10 | 14 | 8 | | Adler-32 | 4 | 6 | 8 | | Whirlpool | 64 | 86 | 128 | | Haval-256 | 32 | 44 | 64 | --------------------------------------- SEE ALSO
DBIx::Class::EncodedColumn::Crypt::Eksblowfish::Bcrypt, DBIx::Class::EncodedColumn, Digest AUTHOR
Guillermo Roditi (groditi) <groditi@cpan.org> Based on the Vienna WoC ToDo manager code by Matt S trout (mst) CONTRIBUTORS
See DBIx::Class::EncodedColumn LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2011-04-24 DBIx::Class::EncodedColumn::Digest(3pm)

Check Out this Related Man Page

DBIx::Class::EncodedColumn(3pm) 			User Contributed Perl Documentation			   DBIx::Class::EncodedColumn(3pm)

NAME
DBIx::Class::EncodedColumn - Automatically encode columns SYNOPSIS
In your DBIx::Class Result class (sometimes erroneously referred to as the 'table' class): __PACKAGE__->load_components(qw/EncodedColumn ... Core/); #Digest encoder with hex format and SHA-1 algorithm __PACKAGE__->add_columns( 'password' => { data_type => 'CHAR', size => 40, encode_column => 1, encode_class => 'Digest', encode_args => {algorithm => 'SHA-1', format => 'hex'}, } #SHA-1 / hex encoding / generate check method __PACKAGE__->add_columns( 'password' => { data_type => 'CHAR', size => 40 + 10, encode_column => 1, encode_class => 'Digest', encode_args => {algorithm => 'SHA-1', format => 'hex', salt_length => 10}, encode_check_method => 'check_password', } #MD5 / base64 encoding / generate check method __PACKAGE__->add_columns( 'password' => { data_type => 'CHAR', size => 22, encode_column => 1, encode_class => 'Digest', encode_args => {algorithm => 'MD5', format => 'base64'}, encode_check_method => 'check_password', } #Eksblowfish bcrypt / cost of 8/ no key_nul / generate check method __PACKAGE__->add_columns( 'password' => { data_type => 'CHAR', size => 59, encode_column => 1, encode_class => 'Crypt::Eksblowfish::Bcrypt', encode_args => { key_nul => 0, cost => 8 }, encode_check_method => 'check_password', } In your application code: #updating the value. $row->password('plaintext'); my $digest = $row->password; #checking against an existing value with a check_method $row->check_password('old_password'); #true $row->password('new_password'); $row->check_password('new_password'); #returns true $row->check_password('old_password'); #returns false Note: The component needs to be loaded before Core. DESCRIPTION
This DBIx::Class component can be used to automatically encode a column's contents whenever the value of that column is set. This module is similar to the existing DBIx::Class::DigestColumns, but there is some key differences: "DigestColumns" performs the encode operation on "insert" and "update", and "EncodedColumn" performs the operation when the value is set, or on "new". "DigestColumns" supports only algorithms of the Digest family. "EncodedColumn" employs a set of thin wrappers around different cipher modules to provide support for any cipher you wish to use and wrappers are very simple to write (typically less than 30 lines). "EncodedColumn" supports having more than one encoded column per table and each column can use a different cipher. "Encode" adds only one item to the namespace of the object utilizing it ("_column_encoders"). There is, unfortunately, some features that "EncodedColumn" doesn't support. "DigestColumns" supports changing certain options at runtime, as well as the option to not automatically encode values on set. The author of this module found these options to be non-essential and omitted them by design. Options added to add_column If any one of these options is present the column will be treated as a digest column and all of the defaults will be applied to the rest of the options. encode_enable => 1 Enable automatic encoding of column values. If this option is not set to true any other options will become no-ops. encode_check_method => $method_name By using the encode_check_method attribute when you declare a column you can create a check method for that column. The check method accepts a plain text string, and returns a boolean that indicates whether the digest of the provided value matches the current value. encode_class The class to use for encoding. Available classes are: "Crypt::Eksblowfish::Bcrypt" - uses DBIx::Class::EncodedColumn::Crypt::Eksblowfish::Bcrypt and requires Crypt::Eksblowfish::Bcrypt to be installed "Digest" - uses DBIx::Class::EncodedColumn::Digest requires Digest to be installed as well as the algorithm required (Digest::SHA, Digest::Whirlpool, etc) "Crypt::OpenPGP" - DBIx::Class::EncodedColumn::Crypt::OpenPGP and requires Crypt::OpenPGP to be installed Please see the relevant class's documentation for information about the specific arguments accepted by each and make sure you include the encoding algorithm (e.g. Crypt::OpenPGP) in your application's requirements. EXTENDED METHODS
The following DBIx::Class::ResultSource method is extended: register_column - Handle the options described above. The following DBIx::Class::Row methods are extended by this module: new - Encode the columns on new() so that copy and create DWIM. set_column - Encode values whenever column is set. SEE ALSO
DBIx::Class::DigestColumns, DBIx::Class, Digest AUTHOR
Guillermo Roditi (groditi) <groditi@cpan.org> Inspired by the original module written by Tom Kirkpatrick (tkp) <tkp@cpan.org> featuring contributions from Guillermo Roditi (groditi) <groditi@cpan.org> and Marc Mims <marc@questright.com> CONTRIBUTORS
jshirley - J. Shirley <cpan@coldhardcode.com> kentnl - Kent Fredric <kentnl@cpan.org> mst - Matt S Trout <mst@shadowcat.co.uk> wreis - Wallace reis <wreis@cpan.org> COPYRIGHT
Copyright (c) 2008 - 2009 the DBIx::Class::EncodedColumn "AUTHOR" and "CONTRIBUTORS" as listed above. LICENSE
This library is free software and may be distributed under the same terms as perl itself. perl v5.10.1 2011-04-11 DBIx::Class::EncodedColumn(3pm)
Man Page