DBIx-Raw

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


0.17    January 13, 11:59 AM Houston, TX
        - Fix LICENSE meta name
        - Update POD with number of rows returned by raw update
        - in update() check if encrypt is defined and is '*' before using as an arrayref

0.16    July 30, 12:09 San Jose, CA
        Use old_crypt_key for old_crypt.

0.15    January 6, 00:21 San Jose, CA
        Now use Crypt::Mode::CBC::Easy for encryption

0.14    January 3, 00:28 San Jose, CA
        Added List::Util to deps.

0.13    January 3, 00:23 San Jose, CA
        Fixed encrypt documentation. Added insert/insert encrypt method. Fixed update encrypt method.

0.12    July 10, 10:00 PM Seattle, WA
        removed prints

META.json  view on Meta::CPAN

         "requires" : {
            "Dist::Milla" : "v1.0.20",
            "Test::Pod" : "1.41"
         }
      },
      "runtime" : {
         "requires" : {
            "Carp" : "0",
            "Config::Any" : "0",
            "Crypt::Blowfish" : "0",
            "Crypt::CBC" : "0",
            "Crypt::Mode::CBC::Easy" : "0",
            "DBI" : "0",
            "Digest::MD5" : "0",
            "List::Util" : "0",
            "MIME::Base64" : "0",
            "Moo" : "0",
            "Types::Standard" : "0",
            "perl" : "5.008005",
            "strictures" : "2.000000"
         }
      },

META.yml  view on Meta::CPAN

    - eg
    - examples
    - inc
    - share
    - t
    - xt
requires:
  Carp: '0'
  Config::Any: '0'
  Crypt::Blowfish: '0'
  Crypt::CBC: '0'
  Crypt::Mode::CBC::Easy: '0'
  DBI: '0'
  Digest::MD5: '0'
  List::Util: '0'
  MIME::Base64: '0'
  Moo: '0'
  Types::Standard: '0'
  perl: '5.008005'
  strictures: '2.000000'
resources:
  bugtracker: https://github.com/srchulo/DBIx-Raw/issues

README  view on Meta::CPAN


    DBIx::Raw uses "crypt_key" to encrypt and decrypt all values. You can
    set the crypt key when you create your DBIx::Raw object by passing it
    into "new", providing it to CONFIGURATION FILE, or by setting it with
    its setter method:

        $db->crypt_key("1234");

    It is strongly recommended that you do not use the default "crypt_key".
    The "crypt_key" should be the appropriate length for the "crypt" that
    is set. The default "crypt" uses Crypt::Mode::CBC::Easy, which uses
    Crypt::Cipher::Twofish, which allows key sizes of 128/192/256 bits.

 crypt

    The Crypt::Mode::CBC::Easy object to use for encryption. Default is the
    default Crypt::Mode::CBC::Easy object created with the key "crypt_key".

 use_old_crypt

    In version 0.16 DBIx::Raw started using Crypt::Mode::CBC::Easy instead
    of DBIx::Raw::Crypt. Setting this to 1 uses the old encryption instead.
    Make sure to set "old_crypt_key" if you previously used "crypt_key" for
    encryption.

 old_crypt_key

    This sets the crypt key to use if "use_old_crypt" is set to true.
    Default is the previous crypt key.

SUBROUTINES/METHODS

cpanfile  view on Meta::CPAN

requires 'perl', '5.008005';

requires 'strictures', '2.000000';
requires 'Moo';
requires 'Types::Standard';
requires 'DBI';
requires 'Config::Any';
requires 'Carp';
requires 'List::Util';
requires 'Crypt::Mode::CBC::Easy';

requires 'Crypt::CBC';
requires 'Crypt::Blowfish';
requires 'MIME::Base64';
requires 'Digest::MD5';

on test => sub {
    requires 'Test::More', '0.96';
    requires 'Test::Carp';
    requires 'DBD::SQLite';
    requires 'YAML::XS';
    requires 'Cwd';

lib/DBIx/Raw.pm  view on Meta::CPAN

our $VERSION = '0.23';

use strictures 2;
use Moo;
use Types::Standard qw/Bool HashRef InstanceOf Str/;
use DBI;
use Config::Any;
use DBIx::Raw::Crypt;
use Carp;
use List::Util qw/first/;
use Crypt::Mode::CBC::Easy;

#have an errors file to write to
has 'dsn' => is => 'rw';
has 'user' => is => 'rw';
has 'password' => is => 'rw';
has 'conf' => is => 'rw';
has 'prev_conf' => (
    is => 'rw',
    isa => Str,
    default => '',
);

has 'crypt' => (
	is => 'ro',
	isa => InstanceOf['Crypt::Mode::CBC::Easy'],
	lazy => 1,
	builder => sub {
		my ($self) = @_;
		return Crypt::Mode::CBC::Easy->new(key => $self->crypt_key);
	},
);

has 'crypt_key' => (
    is => 'rw',
    isa => Str,
    lazy => 1,
    builder => sub {
        my $crypt_key_hex = 'aea77496999d37bf47aedff9c0d44fdf2d2bbfa848ee6652abe9891b43e0f331';
        return pack "H*", $crypt_key_hex;

lib/DBIx/Raw.pm  view on Meta::CPAN


=head2 crypt_key

L<DBIx::Raw> uses L</"crypt_key"> to encrypt and decrypt all values. You can set the crypt key when you create your
L<DBIx::Raw> object by passing it into L</new>, providing it to L<CONFIGURATION FILE|DBIx::Raw/"CONFIGURATION FILE">,
or by setting it with its setter method:

    $db->crypt_key("1234");

It is strongly recommended that you do not use the default L</"crypt_key">. The L</crypt_key> should be the appropriate length
for the L</crypt> that is set. The default L</crypt> uses L<Crypt::Mode::CBC::Easy>, which uses L<Crypt::Cipher::Twofish>, which
allows key sizes of 128/192/256 bits.

=head2 crypt

The L<Crypt::Mode::CBC::Easy> object to use for encryption. Default is the default L<Crypt::Mode::CBC::Easy> object
created with the key L</crypt_key>.

=head2 use_old_crypt

In version 0.16 L<DBIx::Raw> started using L<Crypt::Mode::CBC::Easy> instead of L<DBIx::Raw::Crypt>. Setting this to 1 uses the old encryption instead.
Make sure to set L</old_crypt_key> if you previously used L</crypt_key> for encryption.

=head2 old_crypt_key

This sets the crypt key to use if L</use_old_crypt> is set to true. Default is the previous crypt key.

=head1 SUBROUTINES/METHODS

=head2 raw

lib/DBIx/Raw/Crypt.pm  view on Meta::CPAN

# THIS IS BORROWED FROM Gantry::Utils::Crypt
# He did not have Crypt::CBC listed as a dependency, and didn't fix it
# even though it was listed as a bug several years ago. Thus, I have copied
# this into my package so that installation will work. Also, since this was a
# part of the Gantry web Framework, it would install a lot of unnecessary modules
# not needed for DBIx::Raw. So I have copied this here for my own use. If you are
# interested in using this crypt functionality, please see Gantry::Utils::Crypt instead
# of using this module
package DBIx::Raw::Crypt;
use strict;

use Crypt::CBC;
use MIME::Base64;
use Digest::MD5 qw( md5_hex );

sub new {
    my ( $class, $opt ) = @_;

    my $self = { options => $opt };
    bless( $self, $class );

    my @errors;

lib/DBIx/Raw/Crypt.pm  view on Meta::CPAN

sub decrypt { 
    my ( $self, $encrypted ) = @_;

    $encrypted ||= '';
    $self->set_error( undef );
    
    local $^W = 0;
    
    my $c;
    eval {
        $c = new Crypt::CBC ( {    
            'key'         => $self->{options}{secret},
            'cipher'      => 'Blowfish',
            'padding'     => 'null',
        } );
    };
    if ( $@ ) {
        my $error = (
            "Error building CBC object are your Crypt::CBC and"
            . " Crypt::Blowfish up to date?  Actual error: $@"
        );
        
        $self->set_error( $error );   
        die $error;
    }

    my $p_text = $c->decrypt( MIME::Base64::decode( $encrypted ) );
    
    $c->finish();

lib/DBIx/Raw/Crypt.pm  view on Meta::CPAN

# encrypt
#-------------------------------------------------
sub encrypt {
    my ( $self, @to_encrypt ) = @_;

    local $^W = 0;    
    $self->set_error( undef );
    
    my $c;
    eval {
        $c = new Crypt::CBC( {    
            'key'         => $self->{options}{secret},
            'cipher'     => 'Blowfish',
            'padding'    => 'null',
        } );
    };
    if ( $@ ) {
        my $error = (
            "Error building CBC object are your Crypt::CBC and"
            . " Crypt::Blowfish up to date?  Actual error: $@"
        );

        $self->set_error( $error );
        die $error;
    }

    my $md5 = md5_hex( join( '', @to_encrypt ) );
    push ( @to_encrypt, $md5 );
    



( run in 1.428 second using v1.01-cache-2.11-cpan-e1769b4cff6 )