DBIx-Class-EncodedColumn-0.00020000755001751001751 013542657241 16437 5ustar00wallacewallace000000000000README100644001751001751 1340313542657241 17421 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020NAME 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 and other components such as Timestamp. Core should always be last. E.g: __PACKAGE__->load_components(qw/EncodedColumn TimeStamp 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 encode_column => 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) Inspired by the original module written by Tom Kirkpatrick (tkp) featuring contributions from Guillermo Roditi (groditi) and Marc Mims CONTRIBUTORS jshirley - J. Shirley kentnl - Kent Fredric mst - Matt S Trout wreis - Wallace reis COPYRIGHT Copyright (c) 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. Changes100644001751001751 423113542657241 20013 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020Revision history for Message-Passing-Fluentd 0.00020 2019-09-25 - Skip author tests unless AUTHOR_TESTING is set 0.00019 2019-09-19 - Skip author tests unless DBIC::TimeStamp is avail 0.00018 2019-09-16 08:00:00 - Bugfix author tests (#130447, by jplesnik) - Previous release was broken 0.00017 2019-09-03 - Add '.' to @inc (perlpunk) - Update prereqs (perlpunk) 0.00016 2019-06-12 - Add charset option in ::Digest to handle non-ASCII strings, RT#127553 (rrwo) 0.00015 2016-06-01 - Build fixes 0.00014 2016-05-31 - prevent warning in ::Bcrypt when password is undef - Allow users to specify the Cipher used when encoding 0.00013 2014-02-27 - Pod fixes (RT#88875) - Fix deps (github#1) 0.00012 2013-04-29 - Fixes reported bug #78091. (gbjk++) 0.00011 2011-04-11 - Docs fixes 0.00010 2010-08-27 - Support for crypt() 0.00009 2010-05-17 - Rewritten test suite 0.00008 2010-04-30 - Fix packaging bug. 0.00007 2010-04-29 - Fix for inter-component leaks because of improper mk_classdata usage (fixes RT #5099 by Kent Fredric) ( groditi ) 0.00006 2010-01-15 - Fix build_requires version number for SQLA ( Arthur Axel "fREW" Schmidt ) - Don't encode undef ( osfameron ) 0.00005 2009-10-11 - Fix hashing/validation with Whirlpool ( Kent Fredric ) - Add Repository META 0.00004 2009-09-03 - correct option name typo in the docs (digest_class -> encode_class) - put the .gpg files back into the test so tests pass (mst == fool) 0.00003 2009-09-01 - fixup copyright and licensing info to the proposed new best practice for /^DBIx::Class/ modules - close dbh before unlinking so tests pass on win32 0.00002 2008-07-27 - Support for Crypt::OpenPGP 0.00001 2008-02-01 - No changes 0.00001_03 2008-01-31 - Pod Changes and corrections - Added common digest lengths table 0.00001_02 2008-01-31 -salt additions & little fixes 0.00001_01 2008-01-29 - Initial release LICENSE100644001751001751 4400713542657241 17552 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020This software is copyright (c) 1 by Guillermo Roditi (groditi) . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 1 by Guillermo Roditi (groditi) . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 1 by Guillermo Roditi (groditi) . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End cpanfile100644001751001751 105013542657241 20220 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020# Specific dependencies requires 'DBIx::Class' => '0.06002'; requires 'Sub::Name' => '0.04'; requires 'Encode'; recommends 'Digest'; recommends 'Digest::SHA'; recommends 'Crypt::OpenPGP'; # TODO: remove once Crypt::OpenPGP is fixed recommends 'Math::Pari'; on test => sub { requires 'Test::Exception'; requires 'Test::More'; requires 'DBD::SQLite'; requires 'Dir::Self'; requires 'File::Temp'; requires 'File::Spec'; }; on develop => sub { requires 'Crypt::Eksblowfish::Bcrypt'; requires 'DBIx::Class::TimeStamp'; }; dist.ini100644001751001751 1113542657241 20114 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020[@Milla] Build.PL100644001751001751 27313542657241 17776 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020# This Build.PL for DBIx-Class-EncodedColumn was generated by Dist::Zilla::Plugin::ModuleBuildTiny 0.015. use strict; use warnings; use 5.006; use Module::Build::Tiny 0.034; Build_PL(); META.yml100644001751001751 301513542657241 17770 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020--- abstract: 'Automatically encode columns' author: - 'Guillermo Roditi (groditi) ' build_requires: DBD::SQLite: '0' Dir::Self: '0' File::Spec: '0' File::Temp: '0' Test::Exception: '0' Test::More: '0' configure_requires: Module::Build::Tiny: '0.034' dynamic_config: 0 generated_by: 'Dist::Milla version v1.0.20, Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150005' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: DBIx-Class-EncodedColumn no_index: directory: - eg - examples - inc - share - t - xt recommends: Crypt::OpenPGP: '0' Digest: '0' Digest::SHA: '0' Math::Pari: '0' requires: DBIx::Class: '0.06002' Encode: '0' Sub::Name: '0.04' resources: bugtracker: https://github.com/wreis/DBIx-Class-EncodedColumn/issues homepage: https://github.com/wreis/DBIx-Class-EncodedColumn repository: https://github.com/wreis/DBIx-Class-EncodedColumn.git version: '0.00020' x_contributors: - 'Jonathan Scott Duff ' - 'Jonathan Scott Duff ' - 'Jonathan Yu ' - 'Lisa Hare ' - 'Peter Mottram ' - 'Robert Rothenberg ' - 'Tina Mueller ' - 'Wallace Reis ' - 'Wallace Reis ' - 'wreis ' x_generated_by_perl: v5.24.1 x_serialization_backend: 'YAML::Tiny version 1.73' x_static_install: 1 MANIFEST100644001751001751 206013542657241 17647 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.012. Build.PL Changes LICENSE MANIFEST META.json META.yml README cpanfile dist.ini etc/make_test_ddl_dir.pl lib/DBIx/Class/EncodedColumn.pm lib/DBIx/Class/EncodedColumn/Crypt.pm lib/DBIx/Class/EncodedColumn/Crypt/Eksblowfish/Bcrypt.pm lib/DBIx/Class/EncodedColumn/Crypt/OpenPGP.pm lib/DBIx/Class/EncodedColumn/Digest.pm t/author-pod-syntax.t t/author/timestamp.t t/author/timestamp_order.t t/bcrypt.t t/class_level_encoders.t t/crypt.t t/digest_sha.t t/lib/DigestTest/Schema.pm t/lib/DigestTest/Schema/Bcrypt.pm t/lib/DigestTest/Schema/PGP.pm t/lib/DigestTest/Schema/SHA.pm t/lib/DigestTest/Schema/Whirlpool.pm t/lib/DigestTest/Schema/WithTimeStamp.pm t/lib/DigestTest/Schema/WithTimeStampChild.pm t/lib/DigestTest/Schema/WithTimeStampChildWrongOrder.pm t/lib/DigestTest/Schema/WithTimeStampParent.pm t/lib/DigestTest/Schema/WithTimeStampParentWrongOrder.pm t/lib/DigestTest/Schema/pubring.gpg t/lib/DigestTest/Schema/secring.gpg t/open_pgp.t t/var/DigestTest-Schema-1.x-SQLite.sql t/whirlpool.t t000755001751001751 013542657241 16623 5ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020crypt.t100644001751001751 205513542657241 20313 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/tuse strict; use warnings; use Test::More; use Test::Exception; use DBIx::Class::EncodedColumn::Crypt; my $gen_salt_meth = sub { my @salt_vals = (qw(. /), '0'..'9', 'a'..'z', 'A'..'Z'); return $salt_vals[int(rand(64))] . $salt_vals[int(rand(64))]; }; my ( $col_name, $col_info ) = ( 'password', { salt => $gen_salt_meth } ); my $passwd = 'mypasswd'; my $cripted_pass = crypt($passwd, $gen_salt_meth->()); throws_ok { DBIx::Class::EncodedColumn::Crypt->make_encode_sub( $col_name, { salt => $gen_salt_meth->() } ) } qr{valid.*coderef}i; my $encoder = DBIx::Class::EncodedColumn::Crypt->make_encode_sub( $col_name, $col_info ); my $checker = DBIx::Class::EncodedColumn::Crypt->make_check_sub( $col_name, $col_info ); package MyEncodedColumn; sub new { return bless {}, shift } sub get_column { return $cripted_pass } sub _column_encoders { return { $col_name => $encoder } } package main; isnt($passwd, $encoder->($passwd)); is($cripted_pass, $encoder->($passwd, $cripted_pass)); ok($checker->(MyEncodedColumn->new, $passwd)); done_testing(); META.json100644001751001751 507413542657241 20147 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020{ "abstract" : "Automatically encode columns", "author" : [ "Guillermo Roditi (groditi) " ], "dynamic_config" : 0, "generated_by" : "Dist::Milla version v1.0.20, Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150005", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "DBIx-Class-EncodedColumn", "no_index" : { "directory" : [ "eg", "examples", "inc", "share", "t", "xt" ] }, "prereqs" : { "configure" : { "requires" : { "Module::Build::Tiny" : "0.034" } }, "develop" : { "requires" : { "Crypt::Eksblowfish::Bcrypt" : "0", "DBIx::Class::TimeStamp" : "0", "Dist::Milla" : "v1.0.20", "Test::Pod" : "1.41" } }, "runtime" : { "recommends" : { "Crypt::OpenPGP" : "0", "Digest" : "0", "Digest::SHA" : "0", "Math::Pari" : "0" }, "requires" : { "DBIx::Class" : "0.06002", "Encode" : "0", "Sub::Name" : "0.04" } }, "test" : { "requires" : { "DBD::SQLite" : "0", "Dir::Self" : "0", "File::Spec" : "0", "File::Temp" : "0", "Test::Exception" : "0", "Test::More" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/wreis/DBIx-Class-EncodedColumn/issues" }, "homepage" : "https://github.com/wreis/DBIx-Class-EncodedColumn", "repository" : { "type" : "git", "url" : "https://github.com/wreis/DBIx-Class-EncodedColumn.git", "web" : "https://github.com/wreis/DBIx-Class-EncodedColumn" } }, "version" : "0.00020", "x_contributors" : [ "Jonathan Scott Duff ", "Jonathan Scott Duff ", "Jonathan Yu ", "Lisa Hare ", "Peter Mottram ", "Robert Rothenberg ", "Tina Mueller ", "Wallace Reis ", "Wallace Reis ", "wreis " ], "x_generated_by_perl" : "v5.24.1", "x_serialization_backend" : "Cpanel::JSON::XS version 4.08", "x_static_install" : 1 } bcrypt.t100644001751001751 270013542657241 20452 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/tuse strict; use warnings; use Test::More; use utf8; use Dir::Self; use File::Spec; use File::Temp 'tempdir'; use lib File::Spec->catdir(__DIR__, 'lib'); BEGIN { if( eval 'require Crypt::Eksblowfish::Bcrypt' ){ plan tests => 12; use_ok('DigestTest::Schema'); } else { plan skip_all => 'Crypt::Eksblowfish::Bcrypt not available'; exit; } } #1 DigestTest::Schema->load_classes('Bcrypt'); my $tmp = tempdir( CLEANUP => 1 ); my $db_file = File::Spec->catfile($tmp, 'testdb.sqlite'); my $schema = DigestTest::Schema->connect("dbi:SQLite:dbname=${db_file}"); $schema->deploy({}, File::Spec->catdir(__DIR__, 'var')); my %create_values = (bcrypt_1 => 'test1', bcrypt_2 => 'test1'); my $row = $schema->resultset('Bcrypt')->create( \%create_values ); is( length($row->bcrypt_1), 60, 'correct length'); is( length($row->bcrypt_2), 59, 'correct length'); ok( $row->bcrypt_1_check('test1')); ok( $row->bcrypt_2_check('test1')); $row->bcrypt_1('test2'); $row->bcrypt_2('test2'); ok( $row->bcrypt_1_check('test2')); ok( $row->bcrypt_2_check('test2')); $row->bcrypt_1('官话'); $row->update; ok($row->bcrypt_1_check('官话')); # setting to undef avoids call to make_encode_sub $row->bcrypt_1(undef); $row->bcrypt_2(undef); is( $row->bcrypt_1, undef, 'is undef' ); is( $row->bcrypt_2, undef, 'is undef' ); ok( !$row->bcrypt_1_check(undef), "encode_check_method fails for undef"); ok( !$row->bcrypt_2_check(undef), "encode_check_method fails for undef"); open_pgp.t100644001751001751 360513542657241 20763 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/tuse strict; use warnings; use Test::More; use Dir::Self; use File::Spec; use File::Temp 'tempdir'; use lib File::Spec->catdir(__DIR__, 'lib'); use DigestTest::Schema; BEGIN { my $math_pari = $ENV{'NO_MATH_PARI'} ? 1 : eval 'require Math::Pari'; if( eval 'require Crypt::OpenPGP' && $math_pari ){ plan tests => 8; } else { plan skip_all => 'Crypt::OpenPGP not available'; exit; } } #1 DigestTest::Schema->load_classes('PGP'); my $tmp = tempdir( CLEANUP => 1 ); my $db_file = File::Spec->catfile($tmp, 'testdb.sqlite'); my $schema = DigestTest::Schema->connect("dbi:SQLite:dbname=${db_file}"); $schema->deploy({}, File::Spec->catdir(__DIR__, 'var')); my $row = $schema->resultset('PGP')->create( { dummy_col => 'Dummy Column', pgp_col_passphrase => 'Test Encrypted Column with Passphrase', pgp_col_key => 'Test Encrypted Column with Key Exchange', pgp_col_key_ps => 'Test Encrypted Column with Key Exchange + Pass', pgp_col_rijndael256 => 'Test Encrypted Column with Rijndael256 Cipher', } ); like($row->pgp_col_passphrase, qr/BEGIN PGP MESSAGE/, 'Passphrase encrypted'); like($row->pgp_col_key, qr/BEGIN PGP MESSAGE/, 'Key encrypted'); like($row->pgp_col_key_ps, qr/BEGIN PGP MESSAGE/, 'Key+Passphrase encrypted'); like($row->pgp_col_rijndael256, qr/BEGIN PGP MESSAGE/, 'Rijndael encrypted'); is( $row->decrypt_pgp_passphrase('Secret Words'), 'Test Encrypted Column with Passphrase', 'Passphrase decryption/encryption' ); is( $row->decrypt_pgp_key, 'Test Encrypted Column with Key Exchange', 'Key Exchange decryption/encryption' ); is( $row->decrypt_pgp_key_ps('Secret Words'), 'Test Encrypted Column with Key Exchange + Pass', 'Secured Key Exchange decryption/encryption' ); is( $row->decrypt_pgp_rijndael256('Secret Words'), 'Test Encrypted Column with Rijndael256 Cipher', 'Passphrase decryption/encryption with Rijndael256 Cipher' ); whirlpool.t100644001751001751 360313542657241 21171 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/tuse strict; use warnings; use Test::More; use Dir::Self; use File::Spec; use File::Temp 'tempdir'; use lib File::Spec->catdir(__DIR__, 'lib'); use DigestTest::Schema; BEGIN { if( eval 'require Digest; 1' && eval 'require Digest::Whirlpool; 1' ){ plan tests => 7; } else { plan skip_all => 'Digest::Whirlpool not available'; exit; } } #1 DigestTest::Schema->load_classes('Whirlpool'); my $tmp = tempdir( CLEANUP => 1 ); my $db_file = File::Spec->catfile($tmp, 'testdb.sqlite'); my $schema = DigestTest::Schema->connect("dbi:SQLite:dbname=${db_file}"); $schema->deploy({}, File::Spec->catdir(__DIR__, 'var')); my $checks = {}; for my $algorithm( qw/Whirlpool/){ my $maker = Digest->new($algorithm); my $encodings = $checks->{$algorithm} = {}; for my $encoding (qw/base64 hex/){ my $values = $encodings->{$encoding} = {}; my $encoding_method = $encoding eq 'binary' ? 'digest' : ($encoding eq 'hex' ? 'hexdigest' : 'b64digest'); for my $value (qw/test1 test2/){ $maker->reset()->add($value); $values->{$value} = $maker->$encoding_method; } } } my %create_values = (whirlpool_hex => 'test1', whirlpool_b64 => 'test1'); my $row = $schema->resultset('Whirlpool')->create( \%create_values ); is( $row->whirlpool_hex, $checks->{'Whirlpool'}{hex}{test1}, 'Whirlpool hex'); is( $row->whirlpool_b64, $checks->{'Whirlpool'}{base64}{test1}, 'Whirlpool b64'); can_ok( $row, qw/check_whirlpool_hex check_whirlpool_b64/ ); ok( $row->check_whirlpool_hex('test1'), 'Checking hex digest_check_method for Whirlpool'); ok( $row->check_whirlpool_b64('test1'), 'Checking b64 digest_check_method for Whirlpool'); $row->whirlpool_hex('test2'); is( $row->whirlpool_hex, $checks->{'Whirlpool'}{hex}{test2}, 'Checking accessor (Whirlpool)'); $row->update({ whirlpool_b64 => 'test2' }); is( $row->whirlpool_b64, $checks->{'Whirlpool'}{base64}{test2}, 'Checking Update (Whirlpool)'); digest_sha.t100644001751001751 705113542657241 21265 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/tuse utf8; use strict; use warnings; use Test::More; use Dir::Self; use Encode qw/ str2bytes /; use File::Spec; use File::Temp 'tempdir'; use lib File::Spec->catdir(__DIR__, 'lib'); use DigestTest::Schema; BEGIN { if( eval 'require Digest' && eval 'require Digest::SHA' ){ plan tests => 38; } else { plan skip_all => 'Digest::SHA not available'; exit; } } DigestTest::Schema->load_classes('SHA'); my $tmp = tempdir( CLEANUP => 1 ); my $db_file = File::Spec->catfile($tmp, 'testdb.sqlite'); my $schema = DigestTest::Schema->connect("dbi:SQLite:dbname=${db_file}"); $schema->deploy({}, File::Spec->catdir(__DIR__, 'var')); my @test_values = qw( test1 test2 テスト ); my $checks = {}; for my $algorithm( qw/SHA-1 SHA-256/){ my $maker = Digest->new($algorithm); my $encodings = $checks->{$algorithm} = {}; for my $encoding (qw/base64 hex/){ my $values = $encodings->{$encoding} = {}; my $encoding_method = $encoding eq 'binary' ? 'digest' : ($encoding eq 'hex' ? 'hexdigest' : 'b64digest'); for my $value (@test_values){ $maker->add(str2bytes("utf-8", $value)); $values->{$value} = $maker->$encoding_method; } } } my $str = shift @test_values; my %create_values = map { $_ => $str } qw( dummy_col sha1_hex sha1_b64 sha256_hex sha256_b64 sha256_b64_salted ); my $row = $schema->resultset('SHA')->create( \%create_values ); is($row->dummy_col, $str,'dummy on create'); ok(!$row->can('check_dummy_col'), 'no "check_dummy_col" method'); is($row->sha1_hex, $checks->{'SHA-1'}{hex}{$str}, 'hex sha1 on create'); is($row->sha1_b64, $checks->{'SHA-1'}{base64}{$str}, 'b64 sha1 on create'); is($row->sha256_hex, $checks->{'SHA-256'}{hex}{$str}, 'hex sha256 on create'); is($row->sha256b64, $checks->{'SHA-256'}{base64}{$str},'b64 sha256 on create'); is( length($row->sha256_b64_salted), 57, 'correct salted length'); can_ok($row, qw/check_sha1_hex check_sha1_b64/); ok($row->check_sha1_hex($str),'Checking hex digest_check_method'); ok($row->check_sha1_b64($str),'Checking b64 digest_check_method'); ok($row->check_sha256_b64_salted($str), 'Checking salted digest_check_method'); foreach my $str2 (@test_values) { $row->sha1_hex($str2); is($row->sha1_hex, $checks->{'SHA-1'}{hex}{$str2}, 'Checking accessor'); $row->update({sha1_b64 => $str2, dummy_col => $str2}); is($row->sha1_b64, $checks->{'SHA-1'}{base64}{$str2}, 'Checking update'); is($row->dummy_col, $str2, 'dummy on update'); $row->set_column(sha256_hex => $str2); is($row->sha256_hex, $checks->{'SHA-256'}{hex}{$str2}, 'Checking set_column'); $row->sha256b64($str2); is($row->sha256b64, $checks->{'SHA-256'}{base64}{$str2}, 'custom accessor'); $row->update; my $copy = $row->copy({sha256_b64 => $str2}); is($copy->sha1_hex, $checks->{'SHA-1'}{hex}{$str2}, 'hex sha1 on copy'); is($copy->sha1_b64, $checks->{'SHA-1'}{base64}{$str2}, 'b64 sha1 on copy'); is($copy->sha256_hex, $checks->{'SHA-256'}{hex}{$str2}, 'hex sha256 on copy'); is($copy->sha256b64, $checks->{'SHA-256'}{base64}{$str2},'b64 sha256 on copy'); my $new = $schema->resultset('SHA')->new( \%create_values ); is($new->sha1_hex, $checks->{'SHA-1'}{hex}{$str}, 'hex sha1 on new'); is($new->sha1_b64, $checks->{'SHA-1'}{base64}{$str}, 'b64 sha1 on new'); is($new->sha256_hex, $checks->{'SHA-256'}{hex}{$str}, 'hex sha256 on new'); is($new->sha256b64, $checks->{'SHA-256'}{base64}{$str}, 'b64 sha256 on new'); } $row->sha1_hex(undef); $row->update; is($row->sha1_hex, undef, 'Check undef is passed through'); author000755001751001751 013542657241 20125 5ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/ttimestamp.t100644001751001751 257513542657241 22466 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/authoruse strict; use warnings; use Test::More; use utf8; use Dir::Self; use File::Spec; use File::Temp 'tempdir'; use lib File::Spec->catdir(__DIR__, '../', 'lib'); BEGIN { unless ($ENV{AUTHOR_TESTING}) { plan skip_all => 'These are for testing by the author'; exit; } if( eval 'require Crypt::Eksblowfish::Bcrypt' ){ unless( eval 'require DBIx::Class::TimeStamp' ) { plan skip_all => 'DBIx::Class::TimeStamp not available'; exit; } plan tests => 8; use_ok('DigestTest::Schema'); } else { plan skip_all => 'Crypt::Eksblowfish::Bcrypt not available'; exit; } } #1 DigestTest::Schema->load_classes('WithTimeStamp'); my $tmp = tempdir( CLEANUP => 1 ); my $db_file = File::Spec->catfile($tmp, 'testdb.sqlite'); my $schema = DigestTest::Schema->connect("dbi:SQLite:dbname=${db_file}"); $schema->deploy({}, File::Spec->catdir(__DIR__, 'var')); my %create_values = (bcrypt_1 => 'test1', bcrypt_2 => 'test1'); my $row = $schema->resultset('WithTimeStamp')->create( \%create_values ); is( length($row->bcrypt_1), 60, 'correct length'); is( length($row->bcrypt_2), 59, 'correct length'); ok( $row->bcrypt_1_check('test1')); ok( $row->bcrypt_2_check('test1')); $row->bcrypt_1('test2'); $row->bcrypt_2('test2'); ok( $row->bcrypt_1_check('test2')); ok( $row->bcrypt_2_check('test2')); $row->bcrypt_1('官话'); $row->update; ok($row->bcrypt_1_check('官话')); author-pod-syntax.t100644001751001751 45413542657241 22541 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); etc000755001751001751 013542657241 17133 5ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020make_test_ddl_dir.pl100644001751001751 62413542657241 23247 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/etc#! /usr/bin/perl -w use strict; use warnings; use Dir::Self; use lib File::Spec->catdir(__DIR__, '../', 't', 'lib'); use DigestTest::Schema; my $var = File::Spec->catdir(__DIR__, '../', 't', 'var'); DigestTest::Schema->load_classes(qw/SHA PGP Bcrypt Whirlpool/); my $schema = DigestTest::Schema->connect("dbi:SQLite:"); $schema->create_ddl_dir(['SQLite',], undef, $var, undef, {add_drop_table => 0}); class_level_encoders.t100644001751001751 224613542657241 23332 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/tuse strict; use warnings; use Test::More; BEGIN { if( eval 'require Digest' && eval 'require Digest::SHA' ){ plan tests => 1; } else { plan skip_all => 'Digest::SHA not available'; exit; } } { package TestCorrectlySetClassData; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/EncodedColumn Core/); __PACKAGE__->table('test_register_column'); } TestCorrectlySetClassData->add_columns( sha1_hex => { data_type => 'char', is_nullable => 1, size => 40, encode_column => 1, encode_class => 'Digest', encode_args => { format => 'hex', algorithm => 'SHA-1', }, encode_check_method => 'check_sha1_hex', }, ); my $encoders_1 = TestCorrectlySetClassData->_column_encoders; TestCorrectlySetClassData->add_columns( sha1_b64 => { data_type => 'char', is_nullable => 1, size => 27, encode_column => 1, encode_class => 'Digest', encode_args => { algorithm => 'SHA-1', }, encode_check_method => 'check_sha1_b64', }, ); my $encoders_2 = TestCorrectlySetClassData->_column_encoders; isnt($encoders_1, $encoders_2, 'register_column uses fresh ref for econders'); timestamp_order.t100644001751001751 256113542657241 23654 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/authoruse strict; use warnings; use Test::More; use utf8; use Dir::Self; use File::Spec; use File::Temp 'tempdir'; use lib File::Spec->catdir(__DIR__, '..', 'lib'); use DigestTest::Schema; BEGIN { unless ($ENV{AUTHOR_TESTING}) { plan skip_all => 'These are for testing by the author'; exit; } unless( eval 'require DBIx::Class::TimeStamp' ) { plan skip_all => 'DBIx::Class::TimeStamp not available'; exit; } } DigestTest::Schema->load_classes(qw/WithTimeStampChild WithTimeStampChildWrongOrder/); my $tmp = tempdir( CLEANUP => 1 ); my $db_file = File::Spec->catfile($tmp, 'testdb.sqlite'); my $schema = DigestTest::Schema->connect("dbi:SQLite:dbname=${db_file}"); $schema->deploy({}, File::Spec->catdir(__DIR__, '..', 'var')); my %create_values = (username => 'testuser', password => 'password1'); my $row = $schema->resultset('WithTimeStampChild')->create( \%create_values ); ok($row->password ne 'password1','password has been encrypted'); ok($row->created,'... and created has been set'); ok(!$row->updated,'... and updated has not been set'); $row->update({username => 'testuser2'}); ok($row->updated,'when updated, updated has now been set'); my $row_wrong = $schema->resultset('WithTimeStampChildWrongOrder')->create( \%create_values ); ok($row_wrong->password eq 'password1','with the wrong order of components password has not been encrypted'); done_testing(); DigestTest000755001751001751 013542657241 21450 5ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/libSchema.pm100644001751001751 13113542657241 23321 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTestpackage # hide from PAUSE DigestTest::Schema; use base qw/DBIx::Class::Schema/; 1; Schema000755001751001751 013542657241 22650 5ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTestPGP.pm100644001751001751 355713542657241 24006 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTest/Schemapackage # hide from PAUSE DigestTest::Schema::PGP; use strict; use warnings; use base qw/DBIx::Class/; use Dir::Self; use File::Spec; my $pgp_conf = { SecRing => File::Spec->catdir(__DIR__,'secring.gpg'), PubRing => File::Spec->catdir(__DIR__,'pubring.gpg'), }; __PACKAGE__->load_components(qw/EncodedColumn Core/); __PACKAGE__->table('test_pgp'); __PACKAGE__->add_columns( id => { data_type => 'int', is_nullable => 0, is_auto_increment => 1 }, dummy_col => { data_type => 'char', size => 43, encode_column => 0, encode_class => 'Digest', encode_check_method => 'check_dummy_col', }, pgp_col_passphrase => { data_type => 'text', is_nullable => 1, encode_column => 1, encode_class => 'Crypt::OpenPGP', encode_args => { passphrase => 'Secret Words', armour => 1 }, encode_check_method => 'decrypt_pgp_passphrase', }, pgp_col_key => { data_type => 'text', is_nullable => 1, encode_column => 1, encode_class => 'Crypt::OpenPGP', encode_args => { recipient => '1B8924AA', pgp_args => $pgp_conf, armour => 1 }, encode_check_method => 'decrypt_pgp_key', }, pgp_col_key_ps => { data_type => 'text', is_nullable => 1, encode_column => 1, encode_class => 'Crypt::OpenPGP', encode_args => { recipient => '7BEF6294', pgp_args => $pgp_conf, armour => 1 }, encode_check_method => 'decrypt_pgp_key_ps', }, pgp_col_rijndael256 => { data_type => 'text', is_nullable => 1, encode_column => 1, encode_class => 'Crypt::OpenPGP', encode_args => { passphrase => 'Secret Words', armour => 1, pgp_args => $pgp_conf, cipher => 'Rijndael256', }, encode_check_method => 'decrypt_pgp_rijndael256', }, ); __PACKAGE__->set_primary_key('id'); 1; SHA.pm100644001751001751 344513542657241 23767 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTest/Schemapackage # hide from PAUSE DigestTest::Schema::SHA; use strict; use warnings; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/EncodedColumn Core/); __PACKAGE__->table('test_sha'); __PACKAGE__->add_columns( id => { data_type => 'int', is_nullable => 0, is_auto_increment => 1 }, dummy_col => { data_type => 'char', size => 43, encode_column => 0, encode_class => 'Digest', encode_check_method => 'check_dummy_col', encode_args => { charset => 'utf-8' }, }, sha1_hex => { data_type => 'char', is_nullable => 1, size => 40, encode_column => 1, encode_class => 'Digest', encode_args => { format => 'hex', algorithm => 'SHA-1', charset => 'utf-8', }, encode_check_method => 'check_sha1_hex', }, sha1_b64 => { data_type => 'char', is_nullable => 1, size => 27, encode_column => 1, encode_class => 'Digest', encode_args => { algorithm => 'SHA-1', charset => 'utf-8', }, encode_check_method => 'check_sha1_b64', }, sha256_hex => { data_type => 'char', is_nullable => 1, size => 64, encode_column => 1, encode_class => 'Digest', encode_args => { format => 'hex', charset => 'utf-8', }, }, sha256_b64 => { data_type => 'char', is_nullable => 1, size => 43, accessor => 'sha256b64', encode_column => 1, encode_class => 'Digest', encode_args => { charset => 'utf-8' }, }, sha256_b64_salted => { data_type => 'char', is_nullable => 1, size => 57, encode_column => 1, encode_class => 'Digest', encode_check_method => 'check_sha256_b64_salted', encode_args => {salt_length => 14, charset => 'utf-8', } }, ); __PACKAGE__->set_primary_key('id'); 1; Class000755001751001751 013542657241 20761 5ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/lib/DBIxEncodedColumn.pm100644001751001751 1735013542657241 24224 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/lib/DBIx/Classpackage DBIx::Class::EncodedColumn; use strict; use warnings; use base qw/DBIx::Class/; use Sub::Name; __PACKAGE__->mk_classdata( '_column_encoders' ); our $VERSION = '0.00020'; $VERSION = eval $VERSION; sub register_column { my $self = shift; my ($column, $info) = @_; $self->next::method(@_); return unless exists $info->{encode_column} && $info->{encode_column}; $self->throw_exception("'encode_class' is a required argument.") unless exists $info->{encode_class} && defined $info->{encode_class}; my $class = $info->{encode_class}; my $args = exists $info->{encode_args} ? $info->{encode_args} : {}; $self->throw_exception("'encode_args' must be a hashref") unless ref $args eq 'HASH'; $class = join("::", 'DBIx::Class::EncodedColumn', $class); eval "require ${class};"; $self->throw_exception("Failed to use encode_class '${class}': $@") if $@; defined( my $encode_sub = eval{ $class->make_encode_sub($column, $args) }) || $self->throw_exception("Failed to create encoder with class '$class': $@"); $self->_column_encoders({$column => $encode_sub, %{$self->_column_encoders || {}}}); if ( exists $info->{encode_check_method} && $info->{encode_check_method} ){ no strict 'refs'; defined( my $check_sub = eval{ $class->make_check_sub($column, $args) }) || $self->throw_exception("Failed to create checker with class '$class': $@"); my $name = join '::', $self->result_class, $info->{encode_check_method}; *$name = subname $name, $check_sub; } } sub set_column { my $self = shift; return $self->next::method(@_) unless defined $_[1]; my $encs = $self->_column_encoders; if(exists $encs->{$_[0]} && defined(my $encoder = $encs->{$_[0]})){ return $self->next::method($_[0], $encoder->($_[1])); } $self->next::method(@_); } sub new { my($self, $attr, @rest) = @_; my $encoders = $self->_column_encoders; for my $col (grep { defined $encoders->{$_} } keys %$encoders ) { next unless exists $attr->{$col} && defined $attr->{$col}; $attr->{$col} = $encoders->{$col}->( $attr->{$col} ); } return $self->next::method($attr, @rest); } 1; __END__; =head1 NAME DBIx::Class::EncodedColumn - Automatically encode columns =head1 SYNOPSIS In your L 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 B The component needs to be loaded I Core and other components such as Timestamp. Core should always be last. E.g: __PACKAGE__->load_components(qw/EncodedColumn TimeStamp Core/); =head1 DESCRIPTION This L 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 L, but there is some key differences: =over 4 =item C performs the encode operation on C and C, and C performs the operation when the value is set, or on C. =item C supports only algorithms of the L family. C 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). =item C supports having more than one encoded column per table and each column can use a different cipher. =item C adds only one item to the namespace of the object utilizing it (C<_column_encoders>). =back There is, unfortunately, some features that C doesn't support. C 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. =head1 Options added to add_column =head2 encode_column => 1 Enable automatic encoding of column values. If this option is not set to true any other options will become no-ops. =head2 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. =head2 encode_class The class to use for encoding. Available classes are: =over 4 =item C - uses L and requires L to be installed =item C - uses L requires L to be installed as well as the algorithm required (L, L, etc) =item C - L and requires L to be installed =back 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. L) in your application's requirements. =head1 EXTENDED METHODS The following L method is extended: =over 4 =item B - Handle the options described above. =back The following L methods are extended by this module: =over 4 =item B - Encode the columns on new() so that copy and create DWIM. =item B - Encode values whenever column is set. =back =head1 SEE ALSO L, L, L =head1 AUTHOR Guillermo Roditi (groditi) Inspired by the original module written by Tom Kirkpatrick (tkp) featuring contributions from Guillermo Roditi (groditi) and Marc Mims =head1 CONTRIBUTORS jshirley - J. Shirley kentnl - Kent Fredric mst - Matt S Trout wreis - Wallace reis =head1 COPYRIGHT Copyright (c) the DBIx::Class::EncodedColumn L and L as listed above. =head1 LICENSE This library is free software and may be distributed under the same terms as perl itself. =cut Bcrypt.pm100644001751001751 146013542657241 24612 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTest/Schemapackage # hide from PAUSE DigestTest::Schema::Bcrypt; use strict; use warnings; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/EncodedColumn Core/); __PACKAGE__->table('test_bcrypt'); __PACKAGE__->add_columns( id => { data_type => 'int', is_nullable => 0, is_auto_increment => 1 }, bcrypt_1 => { data_type => 'text', is_nullable => 1, size => 60, encode_column => 1, encode_class => 'Crypt::Eksblowfish::Bcrypt', encode_check_method => 'bcrypt_1_check', }, bcrypt_2 => { data_type => 'text', is_nullable => 1, size => 59, encode_column => 1, encode_class => 'Crypt::Eksblowfish::Bcrypt', encode_args => {key_nul => 0, cost => 6 }, encode_check_method => 'bcrypt_2_check', }, ); __PACKAGE__->set_primary_key('id'); 1; pubring.gpg100644001751001751 347513542657241 25166 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTest/SchemaH&H\OSʇڛѯညHg eO܆7-fj 2Vh%.ʏxǽsyUɵI R'mwe. 2rHp{|*ߓ|Q:Z:Ia24r\B/"LJ,sc%wևC[DIѪ~c̬@G`pjFowK9Z\ͽ-FU=ڀTוI'@ysa |\b"x7[&wG"5!|3fp>_&H*&!iUFF}M!-aaSE6^}eLBM}K'!Test Keys ` H&#  {bպ{rۼ`o(&d+m:aO_  H)Y^XAcw_KsN&1eMK;R,`'E~ / un8VhNC%glkȮhٞ"lU5fs×w,c"]VQ2kbPD` ThڔϬ9 cN]% c6R =2 J`u;B.$5g!=F&0j.ԽK4 Ð6{1 3I H) {b5pܶꌁo SJf ޣwPyL]j*hdHalN|РPP* w-|>9԰^>2pR慆' 9gD;1(OFMᎽ t0^O raɏ_?ޯvi|_&]]x'!]$w䇏0oYWh/aӷڥ>GJ;!b˔KXNL|Y7 sbTKf"$aW$PpIfP=;_{k9Q=x>#o MYoRf6 vlg`<эxiZtEߪ_q!,1lZ]BfOYMc NНyGs+5JI8}񥭶K$L=줠IKB J}=!BzvDTest Keys (This is a test key. DO NOT USE.) ` H  &$K(z~Rh!]L#PV}o%O H\6sDh`v䤣CUlxEHO-zRHv[2&-Tepԍ^@cϐ5wrc:s6ﴜ?ʒT p#8*54M`O(%Xرk%c&R58zxA/C FXa/Vc~F8eI˲1s a_h8B_7dtHKWx8II[(c]xlGk}iI H &$ ވ-RE"*m̶dS3j%2u?iWsecring.gpg100644001751001751 400413542657241 25137 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTest/SchemaH&H\OSʇڛѯညHg eO܆7-fj 2Vh%.ʏxǽsyUɵI R'mwe. 2rHp{|*ߓ|Q:Z:Ia24r\B/"LJ,sc%wևC[DIѪ~c̬@G`pjFowK9Z\ͽ-FU=ڀTוI'@ysa |\b"x7[&wG"5!|3fp>_&H*&!iUFF}M!-aaSE6^}eLBM}K''3|`2 uB˹Tt>8RfvkPZ |̲D4X(d/"w!Test Keys ` H&#  {bպ{rۼ`o(&d+m:aO_ XH)Y^XAcw_KsN&1eMK;R,`'E~ / un8VhNC%glkȮhٞ"lU5fs×w,c"]VQ2kbPD` ThڔϬ9 cN]% c6R =2 J`u;B.$5g!=F&0j.ԽK4 Ð6{1 3'3|`C"͛h8`pOǥ#j X^̈5M"mdsBd&I H) {b5X B"'F-D&!ޑ\}pbߏHalN|РPP* w-|>9԰^>2pR慆' 9gD;1(OFMᎽ t0^O raɏ_?ޯvi|_&]]x'!]$w䇏0oYWh/aӷڥ>GJ;!b˔KXNL|Y7 sbTKf"$aW$PpIfP=;_{k9Q=x>#o MYoRf6 vlg`<эxiZtEߪ_q!,1lZ]BfOYMc NНyGs+5JI8}񥭶K$L=줠IKB J}=!BzvwFZbB>/ DTest Keys (This is a test key. DO NOT USE.) ` H  &$K(z~Rh!]L#PV}o%O1H\6sDh`v䤣CUlxEHO-zRHv[2&-Tepԍ^@cϐ5wrc:s6ﴜ?ʒT p#8*54M`O(%Xرk%c&R58zxA/C FXa/Vc~F8eI˲1s a_h8B_7dtHKWx8II[(c]xlGk}i2d3MlpH"" 7jPɫ$I H &$A'f%U,]c2SF5 }QHoJZWhirlpool.pm100644001751001751 160513542657241 25327 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTest/Schemapackage # hide from PAUSE DigestTest::Schema::Whirlpool; use strict; use warnings; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/EncodedColumn Core/); __PACKAGE__->table('test_whirlpool'); __PACKAGE__->add_columns( id => { data_type => 'int', is_nullable => 0, is_auto_increment => 1 }, whirlpool_hex => { data_type => 'char', is_nullable => 1, size => 128, encode_column => 1, encode_class => 'Digest', encode_args => { format => 'hex', algorithm => 'Whirlpool', }, encode_check_method => 'check_whirlpool_hex', }, whirlpool_b64 => { data_type => 'char', is_nullable => 1, size => 86, encode_column => 1, encode_class => 'Digest', encode_args => { algorithm => 'Whirlpool', }, encode_check_method => 'check_whirlpool_b64', }, ); __PACKAGE__->set_primary_key('id'); 1; EncodedColumn000755001751001751 013542657241 23500 5ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/lib/DBIx/ClassCrypt.pm100644001751001751 203213542657241 25274 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/lib/DBIx/Class/EncodedColumnpackage DBIx::Class::EncodedColumn::Crypt; use strict; use warnings; our $VERSION = '0.01'; sub make_encode_sub { my ($class, $col, $args) = @_; my $gen_salt_meth = $args->{'salt'}; die "Valid 'salt' is a coderef which returns the salt string." unless ref $gen_salt_meth eq 'CODE'; return sub { my ($plain_text, $salt) = @_; $salt ||= $gen_salt_meth->(); return crypt($plain_text, $salt); }; } sub make_check_sub { my($class, $col, $args) = @_; #fast fast fast return eval qq^ sub { my \$col_v = \$_[0]->get_column('${col}'); \$_[0]->_column_encoders->{${col}}->(\$_[1], \$col_v) eq \$col_v; } ^ || die($@); } 1; __END__; =head1 NAME DBIx::Class::EncodedColumn::Crypt - Encrypt columns using crypt() =head1 SEE ALSO L =head1 AUTHOR wreis: Wallace reis =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Digest.pm100644001751001751 1451013542657241 25436 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/lib/DBIx/Class/EncodedColumnpackage DBIx::Class::EncodedColumn::Digest; use strict; use warnings; use Digest; use Encode qw( str2bytes ); our $VERSION = '0.00001'; my %digest_lengths = ( 'MD2' => { base64 => 22, binary => 16, hex => 32 }, 'MD4' => { base64 => 22, binary => 16, hex => 32 }, 'MD5' => { base64 => 22, binary => 16, hex => 32 }, 'SHA-1' => { base64 => 27, binary => 20, hex => 40 }, 'SHA-256' => { base64 => 43, binary => 32, hex => 64 }, 'SHA-384' => { base64 => 64, binary => 48, hex => 96 }, 'SHA-512' => { base64 => 86, binary => 64, hex => 128 }, 'CRC-CCITT' => { base64 => 2, binary => 3, hex => 3 }, 'CRC-16' => { base64 => 6, binary => 5, hex => 4 }, 'CRC-32' => { base64 => 14, binary => 10, hex => 8 }, 'Adler-32' => { base64 => 6, binary => 4, hex => 8 }, 'Whirlpool' => { base64 => 86, binary => 64, hex => 128 }, 'Haval-256' => { base64 => 44, binary => 32, hex => 64 }, ); my @salt_pool = ('A' .. 'Z', 'a' .. 'z', 0 .. 9, '+','/','='); sub make_encode_sub { my($class, $col, $args) = @_; my $for = $args->{format} ||= 'base64'; my $alg = $args->{algorithm} ||= 'SHA-256'; my $slen = $args->{salt_length} ||= 0; my $encode = $args->{charset}; die("Valid Digest formats are 'binary', 'hex' or 'base64'. You used '$for'.") unless $for =~ /^(?:hex|base64|binary)$/; defined(my $object = eval{ Digest->new($alg) }) || die("Can't use Digest algorithm ${alg}: $@"); my $format_method = $for eq 'binary' ? 'digest' : ($for eq 'hex' ? 'hexdigest' : 'b64digest'); #thanks Haval for breaking the standard. thanks! $format_method = 'base64digest 'if ($alg eq 'Haval-256' && $for eq 'base64'); my $encoder = sub { my ($plain_text, $salt) = @_; $plain_text = str2bytes($encode, $plain_text, Encode::FB_PERLQQ | Encode::LEAVE_SRC) if $encode; $salt ||= join('', map { $salt_pool[int(rand(65))] } 1 .. $slen); $object->reset()->add($plain_text.$salt); my $digest = $object->$format_method; #print "${plain_text}\t ${salt}:\t${digest}${salt}\n" if $salt; return $digest.$salt; }; #in case i didn't prepopulate it $digest_lengths{$alg}{$for} ||= length($encoder->('test1')); return $encoder; } sub make_check_sub { my($class, $col, $args) = @_; #this is the digest length my $len = $digest_lengths{$args->{algorithm}}{$args->{format}}; die("Unable to find digest length") unless defined $len; my $encode = $args->{charset} || ''; #fast fast fast return eval qq^ sub { my \$col_v = \$_[0]->get_column('${col}'); \$col_v = str2bytes('${encode}', \$col_v, Encode::FB_PERLQQ | Encode::LEAVE_SRC) if '${encode}'; my \$salt = substr(\$col_v, ${len}); \$_[0]->_column_encoders->{${col}}->(\$_[1], \$salt) eq \$col_v; } ^ || die($@); } 1; __END__; =head1 NAME DBIx::Class::EncodedColumn::Digest - Digest backend =head1 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, charset => 'utf-8', }, 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 ... } =head1 DESCRIPTION =head1 ACCEPTED ARGUMENTS =head2 format The encoding to use for the digest. Valid values are 'binary', 'hex', and 'base64'. Will default to 'base64' if not specified. =head2 algorithm The digest algorithm to use for the digest. You may specify any valid L algorithm. Examples are L, L, L etc. Will default to 'SHA-256' if not specified. See L for supported digest algorithms. =head2 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. =head2 charset If the string is not restricted to ASCII, then you will need to specify a character set encoding. See L for a list of encodings. =head1 METHODS =head2 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. =head2 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. =head1 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 | --------------------------------------- =head1 SEE ALSO L, L, L =head1 AUTHOR Guillermo Roditi (groditi) Based on the Vienna WoC ToDo manager code by Matt S trout (mst) =head1 CONTRIBUTORS See L =head1 LICENSE This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut var000755001751001751 013542657241 17413 5ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/tDigestTest-Schema-1.x-SQLite.sql100644001751001751 204313542657241 25313 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/var-- -- Created by SQL::Translator::Producer::SQLite -- Created on Mon May 17 13:22:05 2010 -- BEGIN TRANSACTION; -- -- Table: test_bcrypt -- CREATE TABLE test_bcrypt ( id INTEGER PRIMARY KEY NOT NULL, bcrypt_1 text, bcrypt_2 text ); -- -- Table: test_pgp -- CREATE TABLE test_pgp ( id INTEGER PRIMARY KEY NOT NULL, dummy_col char(43) NOT NULL, pgp_col_passphrase text, pgp_col_key text, pgp_col_key_ps text, pgp_col_rijndael256 text ); -- -- Table: test_sha -- CREATE TABLE test_sha ( id INTEGER PRIMARY KEY NOT NULL, dummy_col char(43) NOT NULL, sha1_hex char(40), sha1_b64 char(27), sha256_hex char(64), sha256_b64 char(43), sha256_b64_salted char(57) ); -- -- Table: test_whirlpool -- CREATE TABLE test_whirlpool ( id INTEGER PRIMARY KEY NOT NULL, whirlpool_hex char(128), whirlpool_b64 char(86) ); -- -- Table: test_timestamp_order -- CREATE TABLE test_timestamp_order ( id INTEGER PRIMARY KEY NOT NULL, username TEXT NOT NULL, password TEXT NOT NULL, created TEXT, updated TEXT ); COMMIT; WithTimeStamp.pm100644001751001751 151213542657241 26104 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTest/Schemapackage # hide from PAUSE DigestTest::Schema::WithTimeStamp; use strict; use warnings; use base qw/DBIx::Class::Core/; __PACKAGE__->load_components(qw/TimeStamp EncodedColumn/); __PACKAGE__->table('test_with_timestamp'); __PACKAGE__->add_columns( id => { data_type => 'int', is_nullable => 0, is_auto_increment => 1 }, bcrypt_1 => { data_type => 'text', is_nullable => 1, size => 60, encode_column => 1, encode_class => 'Crypt::Eksblowfish::Bcrypt', encode_check_method => 'bcrypt_1_check', }, bcrypt_2 => { data_type => 'text', is_nullable => 1, size => 59, encode_column => 1, encode_class => 'Crypt::Eksblowfish::Bcrypt', encode_args => {key_nul => 0, cost => 6 }, encode_check_method => 'bcrypt_2_check', }, ); __PACKAGE__->set_primary_key('id'); 1; Crypt000755001751001751 013542657241 24601 5ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/lib/DBIx/Class/EncodedColumnOpenPGP.pm100644001751001751 1025213542657241 26567 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/lib/DBIx/Class/EncodedColumn/Cryptpackage DBIx::Class::EncodedColumn::Crypt::OpenPGP; use strict; use warnings; use Carp; use Crypt::OpenPGP; our $VERSION = '0.01'; =head1 NAME DBIx::Class::EncodedColumn::Crypt::OpenPGP - Encrypt columns using Crypt::OpenPGP =head1 SYNOPSIS __PACKAGE__->add_columns( 'secret_data' => { data_type => 'TEXT', encode_column => 1, encode_class => 'Crypt::OpenPGP', encode_args => { recipient => '7BEF6294', }, encode_check_method => 'decrypt_data', }; my $row = $schema->resultset('EncryptedClass') ->create({ secret_data => 'This is secret' }); is( $row->decrypt_data('Private Key Passphrase'), 'This is secret', 'PGP/GPG Encryption works!' ); =head1 DESCRIPTION This is a conduit to working with L, so that you can encrypt data in your database using gpg. Currently this module only handles encrypting but it may add signing of columns in the future =head1 CONFIGURATION In the column definition, specify the C hash as listed in the synopsis. The C is required if doing key exchange encryption, or if you want to use symmetric key encryption using a passphrase you can specify a C option: encode_args => { passphrase => "Shared Secret" } If you have a separate path to your public and private key ring file, or if you have alternative L configuration, you can specify the constructor args using the C configuration key: encode_args => { pgp_args => { SecRing => "$FindBin::Bin/var/secring.gpg", PubRing => "$FindBin::Bin/var/pubring.gpg", } } The included tests cover good usage, and it is advised to briefly browse through them. Also, remember to keep your private keys secure! =cut my %VALID_ENCODE_ARGS = ( 'compat' => 'Compat', 'cipher' => 'Cipher', 'compress' => 'Compress', 'mdc' => 'MDC', ); sub make_encode_sub { my ( $class, $col, $args ) = @_; my ( $method, $method_arg ); my $armour = defined $args->{armour} ? $args->{armour} : 0; if ( defined $args->{passphrase} ) { $method = 'Passphrase'; $method_arg = $args->{passphrase}; } elsif ( defined $args->{recipient} ) { $method = 'Recipients'; $method_arg = $args->{recipient}; } my @other; for my $opt (keys %VALID_ENCODE_ARGS) { if ( defined $args->{$opt} ) { push @other, $VALID_ENCODE_ARGS{$opt} => $args->{$opt}; } } my $pgp = _get_pgp_obj_from_args($args); my $encoder = sub { my ( $plain_text, $settings ) = @_; my $val = $pgp->encrypt( Data => $plain_text, $method => $method_arg, Armour => $armour, @other, ); croak "Unable to encrypt $col; check $method parameter (is $method_arg) (and that the key is known)" unless $val; return $val; }; return $encoder; } sub make_check_sub { my ( $class, $col, $args ) = @_; my $pgp = _get_pgp_obj_from_args($args); return sub { my ( $self, $passphrase ) = @_; my $text = $self->get_column($col); my @res; if ( defined $passphrase ) { @res = $pgp->decrypt( Passphrase => $passphrase, Data => $text ); } else { @res = $pgp->decrypt( Data => $text ); } croak $pgp->errstr unless $res[0]; # Handle additional stuff in $res[1] and [2]? return $res[0]; }; } sub _get_pgp_obj_from_args { my ( $args ) = @_; my $pgp; if ( $args->{pgp_args} and ref $args->{pgp_args} eq 'HASH' ) { $pgp = Crypt::OpenPGP->new( %{ $args->{pgp_args} } ); } elsif ( $args->{pgp_object} and $args->{pgp_object}->isa('Crypt::OpenPGP') ) { $pgp = $args->{pgp_object}; } else { $pgp = Crypt::OpenPGP->new; } croak "Unable to get initialize a Crypt::OpenPGP object" unless $pgp; return $pgp; } =head1 AUTHOR J. Shirley =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; WithTimeStampChild.pm100644001751001751 164313542657241 27055 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTest/Schemapackage # hide from PAUSE DigestTest::Schema::WithTimeStampChild; use strict; use warnings; use base qw/DigestTest::Schema::WithTimeStampParent/; __PACKAGE__->table('test_timestamp_order'); __PACKAGE__->add_columns( id => { data_type => 'int', is_nullable => 0, is_auto_increment => 1 }, username => { data_type => 'text', is_nullable => 0 }, password => { data_type => "text", encode_args => { algorithm => "SHA-1", format => "hex", salt_length => 10 }, encode_check_method => "check_password", encode_class => "Digest", encode_column => 1, is_nullable => 0, }, created => { data_type => 'datetime', set_on_create => 1 }, updated => { data_type => 'datetime', set_on_update => 1 } ); __PACKAGE__->set_primary_key('id'); 1; WithTimeStampParent.pm100644001751001751 30213542657241 27232 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTest/Schemapackage # hide from PAUSE DigestTest::Schema::WithTimeStampParent; use strict; use warnings; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/EncodedColumn TimeStamp Core/); 1; WithTimeStampChildWrongOrder.pm100644001751001751 172313542657241 31065 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTest/Schemapackage # hide from PAUSE DigestTest::Schema::WithTimeStampChildWrongOrder; use strict; use warnings; use base qw/DigestTest::Schema::WithTimeStampParentWrongOrder/; __PACKAGE__->table('test_timestamp_order'); __PACKAGE__->add_columns( id => { data_type => 'int', is_nullable => 0, is_auto_increment => 1 }, username => { data_type => 'text', is_nullable => 0 }, password => { data_type => "text", encode_args => { algorithm => "SHA-1", format => "hex", salt_length => 10 }, encode_check_method => "check_password", encode_class => "Digest", encode_column => 1, is_nullable => 0, }, created => { data_type => 'datetime', set_on_create => 1 }, updated => { data_type => 'datetime', set_on_create => 1, set_on_update => 1 } ); __PACKAGE__->set_primary_key('id'); 1; Eksblowfish000755001751001751 013542657241 27061 5ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/lib/DBIx/Class/EncodedColumn/CryptBcrypt.pm100644001751001751 636313542657241 31032 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/lib/DBIx/Class/EncodedColumn/Crypt/Eksblowfishpackage DBIx::Class::EncodedColumn::Crypt::Eksblowfish::Bcrypt; use strict; use warnings; use Crypt::Eksblowfish::Bcrypt (); use Encode qw(is_utf8 encode_utf8); our $VERSION = '0.00001'; sub make_encode_sub { my($class, $col, $args) = @_; my $cost = exists $args->{cost} ? $args->{cost} : 8; my $nul = exists $args->{key_nul} ? $args->{key_nul} : 1; die("Valid 'key_null' values are '1' and '0'. You used '${nul}'.") unless $nul =~ /^[01]$/; die("Valid 'cost' are 1 or 2 digit integers. You used '${cost}'.") unless $cost =~ /^\d\d?$/; $nul = $nul ? 'a' : ''; $cost = sprintf("%02i", 0+$cost); # It must begin with "$2", optional "a", "$", two digits, "$" my $settings_base = join('','$2',$nul,'$',$cost, '$'); my $encoder = sub { my ($plain_text, $settings_str) = @_; if ( is_utf8($plain_text) ) { # Bcrypt expects octets $plain_text = encode_utf8($plain_text); } unless ( $settings_str ) { my $salt = join('', map { chr(int(rand(256))) } 1 .. 16); $salt = Crypt::Eksblowfish::Bcrypt::en_base64( $salt ); $settings_str = $settings_base.$salt; } return Crypt::Eksblowfish::Bcrypt::bcrypt($plain_text, $settings_str); }; return $encoder; } sub make_check_sub { my($class, $col, $args) = @_; #fast fast fast return eval qq^ sub { my \$col_v = \$_[0]->get_column('${col}'); return unless defined \$col_v; \$_[0]->_column_encoders->{${col}}->(\$_[1], \$col_v) eq \$col_v; } ^ || die($@); } 1; __END__; =head1 NAME DBIx::Class::EncodedColumn::Crypt::Eksblowfish::Bcrypt - Eksblowfish bcrypt backend =head1 SYNOPSYS #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', } =head1 DESCRIPTION =head1 ACCEPTED ARGUMENTS =head2 key_nul => [01] Defaults to true. From the L docs Boolean: whether to append a NUL to the password before using it as a key. The algorithm as originally devised does not do this, but it was later modified to do it. The version that does append NUL is to be preferred; not doing so is supported only for backward compatibility. =head2 cost => \d\d? A single or double digit non-negative integer representing the cost of the hash function. Defaults to 8. =head1 METHODS =head2 make_encode_sub $column_name, \%encode_args Returns a coderef that accepts a plaintext value and returns an encoded value =head2 make_check_sub $column_name, \%encode_args Returns a coderef that when given the row object and a plaintext value will return a boolean if the plaintext matches the encoded value. This is typically used for password authentication. =head1 SEE ALSO L, L, L =head1 AUTHOR Guillermo Roditi (groditi) Based on the Vienna WoC ToDo manager code by Matt S trout (mst) =head1 LICENSE This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut WithTimeStampParentWrongOrder.pm100644001751001751 31413542657241 31246 0ustar00wallacewallace000000000000DBIx-Class-EncodedColumn-0.00020/t/lib/DigestTest/Schemapackage # hide from PAUSE DigestTest::Schema::WithTimeStampParentWrongOrder; use strict; use warnings; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/TimeStamp EncodedColumn Core/); 1;