79253171

Date: 2024-12-05 01:40:23
Score: 0.5
Natty:
Report link

The comments were spot on, the library only supports a maximum of 54 bytes. This test confirms it. EQUAL=false begins at 54 bytes. Thank you to the helpers in the comments.

@Test
fun test() {
    for (n in 100 downTo 0) {
        val secureRandom = SecureRandom()
        val bytes = ByteArray(n)
        secureRandom.nextBytes(bytes)
        val password = Base64.getUrlEncoder().withoutPadding().encodeToString(bytes)

        val passwordHash = BCrypt.hashpw(password, BCrypt.gensalt())
        val modified = password.dropLast(1)

        val equal = BCrypt.checkpw(password, passwordHash) && BCrypt.checkpw(modified, passwordHash)
        println("BYTES=$n EQUAL=$equal")
    }
}
Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: SomeKoder