[Dbix-class] DBIx::Class::EncodedColumn Eksblowfish/bcrypt Qs and
typo
Ashley
apv at sedition.com
Sun Mar 29 19:26:58 BST 2009
DBIx::Class::EncodedColumn looks really great and I am looking at
putting it into a new project to handle the passwords but I seem to
be stuck and wanted to report a typo in the Pod too.
"encode_check_method" is listed correct in SHA-1's synopsis sample
but the MD5 and Eksblowfish (which is the one I'm trying to use) both
list it as "digest_check_method" which doesn't exist but
"encode_check_method" does and is in the tests. Trailing close parens
are missing too.
So, in my user class I've got this. It is in a loader generated
schema so it appears after the # DO NOT MODIFY THIS OR ANYTHING ABOVE!
__PACKAGE__->add_columns(
'password' => {
data_type => 'VARCHAR',
is_nullable => 1,
size => 60,
encode_column => 1,
encode_class =>
'Crypt::Eksblowfish::Bcrypt',
encode_args => { key_nul => 0, cost
=> 8 },
encode_check_method => 'check_password',
});
I did try the size of "22" as the docs show but it didn't work either
and the hash result is "60" long so (adjusting in the DB too, hence
the loader stuff so this can be tweaked over and over).
In my Cat app I'm trying to do this:
my $username = $form->param("username");
my $password = $form->param("password");
my $user = $c->model("DBIC::User")->find({ username =>
$username });
my $enc =
DBIx::Class::EncodedColumn::Crypt::Eksblowfish::Bcrypt->
make_encode_sub("$password", { key_nul => 0, cost => 8 });
$c->log->error( "GOOD? " . ( $user->check_password
($password) ? "YES!" : "NO" ) );
$c->log->warn( $enc->($password) );
$c->log->warn( $user->password );
And seeing this in the log:
[error] GOOD? NO
[warn] $2$08$ezi1tkZgNE3s5vTcK7d4SeyevlXy.L/2mHX0a07AlXV3ONdqkUo5S
[warn] $2$08$EaoTBR7W4akZiofOrrRnA.P5.Bwav85xevEWY4cky94yxxrP2uWU6
What am I doing (or assuming) wrong?
Thanks!
-Ashley
More information about the DBIx-Class
mailing list