Skip to content

BCrypt salt should be random for each request #1

@Nawias

Description

@Nawias

There's a problem with your usage of JBCrypt. The salt should be generated at random for each request, that's the whole point of it.

private static final String BCRYPT_SALT = BCrypt.gensalt();

Also, you should be checking passwords using the checkpw() method.

String encryptedPassword = BCrypt.hashpw(jsonRequest.get(PASSWORD_PROPERTY).getAsString(), BCRYPT_SALT);

You won't notice it with this in-memory "database" implementation but in a real-world scenario, all passwords will become invalid once you restart your server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions