// Create a new Enzoic instance - this is our primary interface for making API calls
Enzoic enzoic = new Enzoic(YOUR_API_KEY, YOUR_API_SECRET);
// (Optional) Set a reasonable timeout for our application, in milliseconds.
enzoic.SetRequestTimeout(500);
// Check whether a password has been compromised
if (enzoic.CheckPassword("password-to-test")) {
System.out.println("Password is compromised");
}
else {
System.out.println("Password is not compromised");
}
// Check whether a password has been compromised with extended return information
CheckPasswordExResponse response = enzoic.CheckPasswordEx("password-to-test");
if (response != null) {
System.out.println("Password is compromised");
if (response.isRevealedInExposure()) {
System.out.println("Password has been revealed in a data breach " +
Integer.toString(response.exposureCount()) +
" times and has a relative breach frequency of " +
Integer.toString(response.relativeExposureFrequency()));
}
else {
System.out.println("Password has not been revealed in a data breach, " +
"but exists publicly in cracking dictionaies.");
}
}
else {
System.out.println("Password is not compromised");
}
// Check whether a specific set of credentials are compromised
if (enzoic.CheckCredentials("[email protected]", "password-to-test")) {
System.out.println("Credentials are compromised");
}
else {
System.out.println("Credentials are not compromised");
}
// Use the CheckCredentialsEx call to tweak performance by including the
// date/time of the last check and excluding BCrypt
if (enzoic.CheckCredentialsEx("[email protected]", "password-to-test",
lastCheckTimestamp, new PasswordType[] { PasswordType.BCrypt })) {
System.out.println("Credentials are compromised");
}
else {
System.out.println("Credentials are not compromised");
}
// get all exposures for a given user
ExposuresResponse exposures = enzoic.GetExposuresForUser("[email protected]");
System.out.println(exposures.getCount() + " exposures found for [email protected]");
// now get the full details for the first exposure found
ExposureDetails details = enzoic.GetExposureDetails(exposures.getExposures()[0]);
System.out.println("First exposure for [email protected] was " + details.getTitle());
// get all passwords for a given user - requires special approval,
// contact Enzoic sales
UserPasswords userPasswords = enzoic.GetUserPasswords("[email protected]");
System.out.println("First password for [email protected] was " +
userPasswords.getPasswords[0].getPassword());