### Question:
Security { public static boolean hashMatches(String hashedPassword, String passwordToHash) { if (hashedPassword == null || passwordToHash == null) { throw new APIException("password.cannot.be.null", (Object[]) null); } return hashedPassword.equals(encodeString(passwordToHash)) || hashedPassword.equals(encodeStringSHA1(passwordToHash)) || hashedPassword.equals(incorrectlyEncodeString(passwordToHash)); } private  Security(); static boolean hashMatches(String hashedPassword, String passwordToHash); static String encodeString(String strToEncode); static String getRandomToken(); static String encrypt(String text, byte[] initVector, byte[] secretKey); static String encrypt(String text); static String decrypt(String text, byte[] initVector, byte[] secretKey); static String decrypt(String text); static byte[] getSavedInitVector(); static byte[] generateNewInitVector(); static byte[] getSavedSecretKey(); static byte[] generateNewSecretKey();  }### Answer:
@Test public void hashMatches_shouldMatchStringsHashedWithSha1Algorithm() { Assert.assertTrue(Security.hashMatches("4a1750c8607d0fa237de36c6305715c223415189", "test" + "c788c6ad82a157b712392ca695dfcf2eed193d7f")); }
@Test public void hashMatches_shouldMatchStringsHashedWithSha512AlgorithmAnd128CharactersSalt() { String password = "1d1436658853aceceadd72e92f1ae9089a0000fbb38cea519ce34eae9f28523930ecb212177dbd607d83dc275fde3e9ca648deb557d503ad0bcd01a955a394b2"; String passwordToHash = "test" + "0d7bb319434295261601202e14494b959cdd69c6ceb54ee3890e176ae780ce9edf797f48afde5f39906a6bd75b8a5feeac8f5339615acf7429c7dda85220d329"; Assert.assertTrue(Security.hashMatches(password, passwordToHash)); }
@Test public void hashMatches_shouldMatchStringsHashedWithIncorrectSha1Algorithm() { Assert.assertTrue(Security.hashMatches("4a1750c8607dfa237de36c6305715c223415189", "test" + "c788c6ad82a157b712392ca695dfcf2eed193d7f")); }