private static boolean validatePassword(String enteredPassword, String passwordFromDatabase) {
        String[] hexPasswordComponents = passwordFromDatabase.split(":");
        int numberOfIterations = Integer.parseInt(hexPasswordComponents[0]);
        byte[] saltBytes = readPasswordFromHex(hexPasswordComponents[1]);
        byte[] hashBytes = readPasswordFromHex(hexPasswordComponents[2]);

        PBEKeySpec pbeKeySpec = new PBEKeySpec(enteredPassword.toCharArray(), saltBytes, numberOfIterations, hashBytes.length * 8);
        SecretKeyFactory secretKeyFactory;
        try {
            secretKeyFactory = SecretKeyFactory.getInstance(SECRET_KEY_ALGORITHM);
        } catch (NoSuchAlgorithmException e) {
            throw new ApplicationException("Failed in encryption while fetching secretKeyFactory: " + e.getMessage(), e);
        }
        byte[] testHash = new byte[0];
        try {
            if (secretKeyFactory != null) {
                testHash = secretKeyFactory.generateSecret(pbeKeySpec).getEncoded();
            }
        } catch (InvalidKeySpecException e) {
            throw new ApplicationException("Failed in encryption while validating password: " + e.getMessage(), e);
        }

        int numberOfDifferences = hashBytes.length ^ testHash.length;
        for (int i = 0; i < hashBytes.length && i < testHash.length; i++) {
            numberOfDifferences |= hashBytes[i] ^ testHash[i];
        }
        return numberOfDifferences == 0;
    }