Skip to content

Commit

Permalink
Reduce bcrypt cost
Browse files Browse the repository at this point in the history
The default cost of 12 takes too long to execute. Reduce to 10, the same
as the default cost in Go.

With a cost of 12, login takes anywhere from 200 - 500ms to execute on a
Ryzen 7 3800X in release, and up to 4s in debug. In comparison, a cost
of 10 takes 50ms in release and 200ms in debug.
  • Loading branch information
Aleksbgbg committed Feb 10, 2024
1 parent 1242b01 commit 8b8a0cc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion backend-rs/src/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub async fn create(
) -> Result<User, CreateError> {
let id = snowflakes.user_snowflake.lock().await.get_id();
let time = Local::now().fixed_offset();
let hashed_pasword = bcrypt::hash(user.password, bcrypt::DEFAULT_COST)?;
let hashed_pasword = bcrypt::hash(user.password, 10)?;

Ok(
ActiveModel {
Expand Down

0 comments on commit 8b8a0cc

Please sign in to comment.