Skip to content

Commit c14cafc

Browse files
committed
Use 2a variant of bcrypt
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.
1 parent c368a0b commit c14cafc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/PAUSE/Crypt.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ sub hash_password {
99
my ($pw) = @_;
1010

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

1515
sub password_verify {
@@ -28,7 +28,7 @@ sub password_verify {
2828
sub maybe_upgrade_stored_hash {
2929
my ($arg) = @_;
3030

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

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

0 commit comments

Comments
 (0)