The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Crypt::Bcrypt::Easy - Simple interface to bcrypted passwords

SYNOPSIS

  use Crypt::Bcrypt::Easy;

  my $plain = 'my_password';

  # Same (default cost 08):
  my $passwd = bcrypt->crypt( $plain );
  my $passwd = bcrypt->crypt( text => $plain );
  my $passwd = bcrypt->crypt( text => $plain, cost => 8 );

  if (bcrypt->compare( text => $plain, crypt => $passwd )) {
    # Successful match
  }

  # Generate passwords using a different default workcost:
  my $bc = bcrypt( cost => 10 );
  my $crypted = $bc->crypt( $plain );

DESCRIPTION

This module provides an alternate interface to App::bmkpasswd's exported helpers (which were created to power bmkpasswd and are a bit awkward to use directly).

This POD briefly covers usage of this interface; see App::bmkpasswd for more details.

This module uses Exporter::Tiny; you can rename the "bcrypt" function as-needed:

  use Crypt::Bcrypt::Easy 'bcrypt' => { -as => 'bc' };

bcrypt

  my $bcrypt = bcrypt( cost => '10' );

Creates and returns a new Crypt::Bcrypt::Easy object.

The default workcost is '08'. This can be also be tuned for individual runs; see "crypt".

crypt

  my $passwd = bcrypt->crypt(
    text   => 'my_password',
    cost   => 8,
    strong => 0,
  );

Or use defaults:

  my $passwd = bcrypt->crypt( 'my_password' );

Create and return a new password hash.

Specifying a boolean true 'strong =>' parameter enables strongly-random salts (see App::bmkpasswd).

compare

  if (bcrypt->compare(text => 'my_password', crypt => $passwd)) {
     ...
  }

Returns boolean true if hashes match. Accepts any type of hash supported by your App::bmkpasswd; see passwdcmp from App::bmkpasswd.

cost

Returns the current work-cost value.

AUTHOR

Jon Portnoy <avenj@cobaltirc.org>