private boolean digestMatches(byte[] digest, String providedDigest) {
        return providedDigest.equalsIgnoreCase(Hex.encodeHexString(digest)) || providedDigest.equalsIgnoreCase(new String(Base64.getEncoder().encode(digest)));
    }
private boolean digestMatches ( byte [ ] digest , String providedDigest ) { return providedDigest . equalsIgnoreCase ( Hex . encodeHexString ( digest ) ) || providedDigest . equalsIgnoreCase ( new String ( Base64 . getEncoder ( ) . encode ( digest ) ) ) ; }
Utility method supporting both possible digest formats: Base64 and Hex