Rose::DB::Object::MakeMethods::EKSBlowfish - Create Blowfish-specific object methods for Rose::DB::Object-derived objects.
Version 0.01
package MyDBObject; our @ISA = qw(Rose::DB::Object); use Rose::DBx::Object::MakeMethods::EKSBlowfish( eksblowfish => [ 'type' => { cost => 8, key_nul => 0, }, ], ); ... $o = MyDBObject->new(...); $o->password('foobar'); # Something like: "$2$08$NWgpob52QKA2fRUgCwB93O1qoHZGu/Kr9iGfI/2nhy9uc9R2IG9by" print $o->password_encrypted; print $o->password; # "foobar" print "ok" if($o->password_is('foobar'); # "ok"
Rose::DB::Object::MakeMethods::EKSBlowfish creates methods that deal with eksblowfish encrypted passwords. It inherits from Rose::Object::MakeMethods. See the Rose::Object::MakeMethods documentation to learn about the interface. The method types provided by this module are described below.
Rose::DB::Object::MakeMethods::EKSBlowfish
All method types defined by this module are designed to work with objects that are subclasses of (or otherwise conform to the interface of) Rose::DB::Object. In particular, the object is expected to have a db method that returns a Rose::DB-derived object. See the Rose::DB::Object documentation for more details.
db
Create a family methods for handling eksblowfish encrypted passwords.
cmp_suffix
The string appended to the default method name to form the name of the comparison method. Defaults to "_is".
encrypted_suffix
The string appended to the default method name to form the name of the get/set method that handles the encrypted version of the CHKPASS value. Defaults to "_encrypted".
hash_key
The key inside the hash-based object to use for the storage of the unencrypted value. Defaults to the name of the method.
The encrypted value is stored in a hash key with the same name, but with encrypted_suffix appended.
get_set
Creates a family of methods for handling eksblowfish encrypted passwords. The methods are:
default
The get/set method for the unencrypted value. (This method uses the default method name.) If called with no arguments, the unencrypted value is returned, if it is known. If not, undef is returned.
If passed an argument that begins with "$", it is assumed to be an encrypted value and is stored as such. Undef is returned, since it is not feasible to determine the unencrypted value based on the encrypted value.
If passed an argument that does not begin with "$", it is taken as the unencrypted value.
encrypted
The get/set method for the encrypted value. The method name will be formed by concatenating the default method name (above) and the value of the encrypted_suffix option.
If called with no arguments, the encrypted value is returned, if it is known. If not, undef is returned.
If passed an argument that begins with "$", it is assumed to be an encrypted value and is stored as such. The unencrypted value is set to undef, since it is not feasible to determine the unencrypted value based on the encrypted value. The encrypted value is returned.
If passed an argument that does not begin with "$", it is taken as the unencrypted value. =item comparison
comparison
This method compares its argument to the unencrypted value and returns true if the two values are identical (string comparison), false if they are not, and undef if both the encrypted and unencrypted values are undefined.
Example:
package MyDBObject; use base qw(Rose::DB::Object); use Rose::DBx::Object::MakeMethods::EKSBlowfish( eksblowfish => [ 'type' => { cost => 8, key_nul => 0, }, ], );:w __PACKAGE__->meta->setup( db => $db, table => 'users', columns => [ id => { type => 'serial', not_null => 1 }, name => { type => 'varchar', length => 255, not_null => 1 }, password => { type => 'eksblowfish', not_null => 1, }, ], primary_key_columns => ['id'], unique_key => ['name'], ); ... $o = MyDBObject->new(...); $o->password('blah'); $o->password('foobar'); # Something like: "$2$08$ft6IhGIrQz1uDJiv6nD7sePuQEfcpb7excBQnDGu2GmDuk7kb5Ie6" print $o->password_encrypted; print $o->get_password; # "foobar" print $o->password; # "foobar" print "ok" if($o->password_is('foobar'); # "ok"
the encryption generator
Holger Rupprecht (holger.rupprecht@gmx.de)
Copyright (c) 2013 by Holger Rupprecht. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1; # End of Rose::DBx::Object::MakeMethods::EKSBlowfish
To install Rose::DBx::Object::MakeMethods::EKSBlowfish, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Rose::DBx::Object::MakeMethods::EKSBlowfish
CPAN shell
perl -MCPAN -e shell install Rose::DBx::Object::MakeMethods::EKSBlowfish
For more information on module installation, please visit the detailed CPAN module installation guide.