package be.simplenotes.domain.security import org.mindrot.jbcrypt.BCrypt internal interface PasswordHash { fun crypt(password: String): String fun verify(password: String, hashedPassword: String): Boolean } internal class BcryptPasswordHash(test: Boolean = false) : PasswordHash { private val rounds = if (test) 4 else 10 override fun crypt(password: String) = BCrypt.hashpw(password, BCrypt.gensalt(rounds))!! override fun verify(password: String, hashedPassword: String) = BCrypt.checkpw(password, hashedPassword) }