@@ -0,0 +1,2137 @@
+import java.io.IOException;%0Aimport java.net.HttpURLConnection;%0Aimport java.net.MalformedURLException;%0Aimport java.net.URL;%0Aimport java.util.Scanner;%0A%0A/*%0A    Simple Java console application that checks if a password has appeared in a known data breach using Troy Hunt's%0A    Have I Been Pwned API (https://haveibeenpwned.com/API/v2).%0A */%0A%0Apublic class pwnedPassword %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        // Obviously this can be changed and edited to something else. This is just%0A        // the most basic example of password checking.%0A        System.out.print(%22Please enter a password: %22);%0A        Scanner scan = new Scanner(System.in);%0A        String password = scan.next();%0A%0A        try %7B%0A            // Open a connection to the API site.%0A            URL url = new URL(%22https://haveibeenpwned.com/api/v2/pwnedpassword/%22 + password);%0A%0A            HttpURLConnection connection = (HttpURLConnection) url.openConnection();%0A            connection.setRequestMethod(%22GET%22);%0A%0A            /*%0A             * @param userAgent: this request header must be set otherwise any call will result in an HTTP 403 response%0A             * userAgent is the application / customer consuming the API.%0A             */%0A%0A            connection.setRequestProperty(%22User-Agent%22, %22Java Pwned Password Checker%22); //Put your application name here%0A            int statusCode = connection.getResponseCode();%0A%0A            // From the API docs, if status code 200 is returned, the password has appeared in a breach.%0A            // If status code is 404, the password has not appeared in a breach.%0A            if (statusCode == 200) System.out.println(%22Your password has been breached. Please consider using a different password.%22);%0A            else if (statusCode == 404) System.out.println(%22Your password is safe. It has not appeared in known data breaches.%22);%0A%0A        %7D catch (MalformedURLException e) %7B%0A            System.out.println(%22Malformed URL: Please enter a valid URL%22);%0A        %7D catch (IOException e) %7B%0A            System.out.println(%22IOException: Please enter a valid URL%22);%0A        %7D finally %7B%0A            scan.close();%0A        %7D%0A    %7D%0A%7D%0A

Create pwnedPassword.java