Skip to content

Commit

Permalink
Use 2a variant of bcrypt
Browse files Browse the repository at this point in the history
The 2 variant has been replaced in almost all places, to the point where
modern bcrypt libraries don't even support it. That is also why I can't
move it to the 2b variant instead (as most of the rest of the world has
since 2014.
  • Loading branch information
Leont committed Apr 25, 2024
1 parent c368a0b commit c14cafc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/PAUSE/Crypt.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sub hash_password {
my ($pw) = @_;

$pw = substr $pw, 0, 72;
my $hash = bcrypt($pw, '$2$12$' . en_base64( urandom(16) ));
my $hash = bcrypt($pw, '$2a$12$' . en_base64( urandom(16) ));
}

sub password_verify {
Expand All @@ -28,7 +28,7 @@ sub password_verify {
sub maybe_upgrade_stored_hash {
my ($arg) = @_;

return if length $arg->{old_hash} > 13; # already bcrypt
return if $arg->{old_hash} =~ /^\$2a\$/; # already bcrypt

my $new_hash = hash_password($arg->{password});

Expand Down

0 comments on commit c14cafc

Please sign in to comment.