Scala client for the "Have I Been Pwned API v2" https://haveibeenpwned.com/API/v2
Find if an email is Pwned:
import io.onema.beenpwned4s.PwnedClient
val client = PwnedClient()
if(client.isEmailBreached("[email protected]")) {
println("Email is pwned")
} else {
println("Email is not pwned")
}
val emailResults: Option[Seq[PwnedClient.Breach]] = client.getEmailBreached("[email protected]")
emailResults.isDefined
println(s"The email has been pwned ${emailResults.get.length} times")
Find if the password is Pwned:
import io.onema.beenpwned4s.PwnedClient
val client = PwnedClient()
if(client.isPasswordPwned("password")) {
println("Password is pwned")
} else {
println("Password is not pwned")
}
val passwordResult: Option[PwnedClient.HashPwned] = client.getPasswordPwned("password")
passwordResult.isDefined
passwordResult.foreach(p => {
println(s"The password-hash suffix ${p.hashSuffix} has been pwned ${p.count} times")
})