Skip to content

Instantly share code, notes, and snippets.

@sc6l6d3v
Created July 16, 2019 15:13
Show Gist options
  • Save sc6l6d3v/52551d24461a32c24cecf642de115ba4 to your computer and use it in GitHub Desktop.
Save sc6l6d3v/52551d24461a32c24cecf642de115ba4 to your computer and use it in GitHub Desktop.
import com.mohiva.play.silhouette.api.util.PasswordInfo
import com.mohiva.play.silhouette.password.BCryptSha256PasswordHasher
import org.mindrot.jbcrypt.BCrypt
class MyBCryptSha256PasswordHasher extends BCryptSha256PasswordHasher {
private val salt = BCrypt.gensalt(16)
override def hash(plainPassword: String) = {
PasswordInfo(
hasher = id,
password = BCrypt.hashpw(plainPassword, salt),
Some(salt)
)
}
override def matches(passwordInfo: PasswordInfo, suppliedPassword: String): Boolean = {
BCrypt.checkpw(suppliedPassword, passwordInfo.password)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment