Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Increase bcrypt rounds to 12 #48494

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Hashing/BcryptHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BcryptHasher extends AbstractHasher implements HasherContract
*
* @var int
*/
protected $rounds = 10;
protected $rounds = 12;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding on @GrahamCampbell - I would suggest having a method here that allows you to set this value as Laravel does it all over the place.

Say

getRounds(): foo
{
 return $this->rounds;
}

Here, you can extend it and leave the default behaviour while allowing people to hook into it. ✋🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, ignore my last comment - I was confused with something else.

You can easily set it outside the class. What's the use case for extending the class itself?


/**
* Indicates whether to perform an algorithm check.
Expand Down
1 change: 1 addition & 0 deletions tests/Hashing/HasherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function testBasicBcryptHashing()
$this->assertFalse($hasher->needsRehash($value));
$this->assertTrue($hasher->needsRehash($value, ['rounds' => 1]));
$this->assertSame('bcrypt', password_get_info($value)['algoName']);
$this->assertGreaterThanOrEqual(12, password_get_info($value)['options']['cost']);
$this->assertTrue($this->hashManager->isHashed($value));
}

Expand Down