/** * This method will hash <code>strToEncode</code> using SHA-1 and the incorrect hashing method * that sometimes dropped out leading zeros. * * @param strToEncode string to encode * @return the SHA-1 encryption of a given string */ private static String incorrectlyEncodeString(String strToEncode) throws APIException { String algorithm = "SHA1"; MessageDigest md; byte[] input; try { md = MessageDigest.getInstance(algorithm); input = strToEncode.getBytes(StandardCharsets.UTF_8); } catch (NoSuchAlgorithmException e) { // Yikes! Can't encode password...what to do? log.error(getPasswordEncodeFailMessage(algorithm), e); throw new APIException("system.cannot.find.encryption.algorithm", null, e); } return incorrectHexString(md.digest(input)); }