Skip to content

Instantly share code, notes, and snippets.

@brianmed
Created October 21, 2013 13:30
Show Gist options
  • Select an option

  • Save brianmed/7083904 to your computer and use it in GitHub Desktop.

Select an option

Save brianmed/7083904 to your computer and use it in GitHub Desktop.

Revisions

  1. brianmed created this gist Oct 21, 2013.
    17 changes: 17 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    sub hash_password {
    my $self = shift;

    my ($plain_text, $settings_str) = @_;

    unless ($settings_str) {
    my $salt = join('', map { chr(int(rand(256))) } 1 .. 16);
    $salt = Crypt::Eksblowfish::Bcrypt::en_base64( $salt );
    return(Crypt::Eksblowfish::Bcrypt::bcrypt_hash({
    key_nul => 1,
    cost => 10,
    salt => $salt,
    }, $password));
    }

    return Crypt::Eksblowfish::Bcrypt::bcrypt($plain_text, $settings_str);
    }