Merge http4k
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user