.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DBIx::Class::EncodedColumn 3pm" .TH DBIx::Class::EncodedColumn 3pm "2019-11-03" "perl v5.30.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DBIx::Class::EncodedColumn \- Automatically encode columns .SH "SYNOPSIS" .IX Header "SYNOPSIS" In your DBIx::Class Result class (sometimes erroneously referred to as the 'table' class): .PP .Vb 1 \& _\|_PACKAGE_\|_\->load_components(qw/EncodedColumn ... Core/); \& \& #Digest encoder with hex format and SHA\-1 algorithm \& _\|_PACKAGE_\|_\->add_columns( \& \*(Aqpassword\*(Aq => { \& data_type => \*(AqCHAR\*(Aq, \& size => 40, \& encode_column => 1, \& encode_class => \*(AqDigest\*(Aq, \& encode_args => {algorithm => \*(AqSHA\-1\*(Aq, format => \*(Aqhex\*(Aq}, \& } \& \& #SHA\-1 / hex encoding / generate check method \& _\|_PACKAGE_\|_\->add_columns( \& \*(Aqpassword\*(Aq => { \& data_type => \*(AqCHAR\*(Aq, \& size => 40 + 10, \& encode_column => 1, \& encode_class => \*(AqDigest\*(Aq, \& encode_args => {algorithm => \*(AqSHA\-1\*(Aq, format => \*(Aqhex\*(Aq, salt_length => 10}, \& encode_check_method => \*(Aqcheck_password\*(Aq, \& } \& \& #MD5 / base64 encoding / generate check method \& _\|_PACKAGE_\|_\->add_columns( \& \*(Aqpassword\*(Aq => { \& data_type => \*(AqCHAR\*(Aq, \& size => 22, \& encode_column => 1, \& encode_class => \*(AqDigest\*(Aq, \& encode_args => {algorithm => \*(AqMD5\*(Aq, format => \*(Aqbase64\*(Aq}, \& encode_check_method => \*(Aqcheck_password\*(Aq, \& } \& \& #Eksblowfish bcrypt / cost of 8/ no key_nul / generate check method \& _\|_PACKAGE_\|_\->add_columns( \& \*(Aqpassword\*(Aq => { \& data_type => \*(AqCHAR\*(Aq, \& size => 59, \& encode_column => 1, \& encode_class => \*(AqCrypt::Eksblowfish::Bcrypt\*(Aq, \& encode_args => { key_nul => 0, cost => 8 }, \& encode_check_method => \*(Aqcheck_password\*(Aq, \& } .Ve .PP In your application code: .PP .Vb 3 \& #updating the value. \& $row\->password(\*(Aqplaintext\*(Aq); \& my $digest = $row\->password; \& \& #checking against an existing value with a check_method \& $row\->check_password(\*(Aqold_password\*(Aq); #true \& $row\->password(\*(Aqnew_password\*(Aq); \& $row\->check_password(\*(Aqnew_password\*(Aq); #returns true \& $row\->check_password(\*(Aqold_password\*(Aq); #returns false .Ve .PP \&\fBNote:\fR The component needs to be loaded \fIbefore\fR Core and other components such as Timestamp. Core should always be last. .PP .Vb 2 \& E.g: \& _\|_PACKAGE_\|_\->load_components(qw/EncodedColumn TimeStamp Core/); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This DBIx::Class component can be used to automatically encode a column's contents whenever the value of that column is set. .PP This module is similar to the existing DBIx::Class::DigestColumns, but there is some key differences: .ie n .IP """DigestColumns"" performs the encode operation on ""insert"" and ""update"", and ""EncodedColumn"" performs the operation when the value is set, or on ""new""." 4 .el .IP "\f(CWDigestColumns\fR performs the encode operation on \f(CWinsert\fR and \f(CWupdate\fR, and \f(CWEncodedColumn\fR performs the operation when the value is set, or on \f(CWnew\fR." 4 .IX Item "DigestColumns performs the encode operation on insert and update, and EncodedColumn performs the operation when the value is set, or on new." .PD 0 .ie n .IP """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)." 4 .el .IP "\f(CWDigestColumns\fR supports only algorithms of the Digest family. \f(CWEncodedColumn\fR 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)." 4 .IX Item "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)." .ie n .IP """EncodedColumn"" supports having more than one encoded column per table and each column can use a different cipher." 4 .el .IP "\f(CWEncodedColumn\fR supports having more than one encoded column per table and each column can use a different cipher." 4 .IX Item "EncodedColumn supports having more than one encoded column per table and each column can use a different cipher." .ie n .IP """Encode"" adds only one item to the namespace of the object utilizing it (""_column_encoders"")." 4 .el .IP "\f(CWEncode\fR adds only one item to the namespace of the object utilizing it (\f(CW_column_encoders\fR)." 4 .IX Item "Encode adds only one item to the namespace of the object utilizing it (_column_encoders)." .PD .PP There is, unfortunately, some features that \f(CW\*(C`EncodedColumn\*(C'\fR doesn't support. \&\f(CW\*(C`DigestColumns\*(C'\fR 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. .SH "Options added to add_column" .IX Header "Options added to add_column" .SS "encode_column => 1" .IX Subsection "encode_column => 1" Enable automatic encoding of column values. If this option is not set to true any other options will become no-ops. .ie n .SS "encode_check_method => $method_name" .el .SS "encode_check_method => \f(CW$method_name\fP" .IX Subsection "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. .SS "encode_class" .IX Subsection "encode_class" The class to use for encoding. Available classes are: .ie n .IP """Crypt::Eksblowfish::Bcrypt"" \- uses DBIx::Class::EncodedColumn::Crypt::Eksblowfish::Bcrypt and requires Crypt::Eksblowfish::Bcrypt to be installed" 4 .el .IP "\f(CWCrypt::Eksblowfish::Bcrypt\fR \- uses DBIx::Class::EncodedColumn::Crypt::Eksblowfish::Bcrypt and requires Crypt::Eksblowfish::Bcrypt to be installed" 4 .IX Item "Crypt::Eksblowfish::Bcrypt - uses DBIx::Class::EncodedColumn::Crypt::Eksblowfish::Bcrypt and requires Crypt::Eksblowfish::Bcrypt to be installed" .PD 0 .ie n .IP """Digest"" \- uses DBIx::Class::EncodedColumn::Digest requires Digest to be installed as well as the algorithm required (Digest::SHA, Digest::Whirlpool, etc)" 4 .el .IP "\f(CWDigest\fR \- uses DBIx::Class::EncodedColumn::Digest requires Digest to be installed as well as the algorithm required (Digest::SHA, Digest::Whirlpool, etc)" 4 .IX Item "Digest - uses DBIx::Class::EncodedColumn::Digest requires Digest to be installed as well as the algorithm required (Digest::SHA, Digest::Whirlpool, etc)" .ie n .IP """Crypt::OpenPGP"" \- DBIx::Class::EncodedColumn::Crypt::OpenPGP and requires Crypt::OpenPGP to be installed" 4 .el .IP "\f(CWCrypt::OpenPGP\fR \- DBIx::Class::EncodedColumn::Crypt::OpenPGP and requires Crypt::OpenPGP to be installed" 4 .IX Item "Crypt::OpenPGP - DBIx::Class::EncodedColumn::Crypt::OpenPGP and requires Crypt::OpenPGP to be installed" .PD .PP 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. .SH "EXTENDED METHODS" .IX Header "EXTENDED METHODS" The following DBIx::Class::ResultSource method is extended: .IP "\fBregister_column\fR \- Handle the options described above." 4 .IX Item "register_column - Handle the options described above." .PP The following DBIx::Class::Row methods are extended by this module: .IP "\fBnew\fR \- Encode the columns on \fBnew()\fR so that copy and create \s-1DWIM.\s0" 4 .IX Item "new - Encode the columns on new() so that copy and create DWIM." .PD 0 .IP "\fBset_column\fR \- Encode values whenever column is set." 4 .IX Item "set_column - Encode values whenever column is set." .PD .SH "SEE ALSO" .IX Header "SEE ALSO" DBIx::Class::DigestColumns, DBIx::Class, Digest .SH "AUTHOR" .IX Header "AUTHOR" Guillermo Roditi (groditi) .PP Inspired by the original module written by Tom Kirkpatrick (tkp) featuring contributions from Guillermo Roditi (groditi) and Marc Mims .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" jshirley \- J. Shirley .PP kentnl \- Kent Fredric .PP mst \- Matt S Trout .PP wreis \- Wallace reis .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) the DBIx::Class::EncodedColumn \*(L"\s-1AUTHOR\*(R"\s0 and \*(L"\s-1CONTRIBUTORS\*(R"\s0 as listed above. .SH "LICENSE" .IX Header "LICENSE" This library is free software and may be distributed under the same terms as perl itself.