Class MessageDigestCalculatingInputStream

    • Field Detail

      • DEFAULT_ALGORITHM

        private static final java.lang.String DEFAULT_ALGORITHM
        The default message digest algorithm.

        The MD5 cryptographic algorithm is weak and should not be used.

        See Also:
        Constant Field Values
      • messageDigest

        private final java.security.MessageDigest messageDigest
    • Constructor Detail

      • MessageDigestCalculatingInputStream

        @Deprecated
        public MessageDigestCalculatingInputStream​(java.io.InputStream inputStream)
                                            throws java.security.NoSuchAlgorithmException
        Creates a new instance, which calculates a signature on the given stream, using a MessageDigest with the "MD5" algorithm.

        The MD5 algorithm is weak and should not be used.

        Parameters:
        inputStream - the stream to calculate the message digest for
        Throws:
        java.security.NoSuchAlgorithmException - if no Provider supports a MessageDigestSpi implementation for the specified algorithm.
      • MessageDigestCalculatingInputStream

        @Deprecated
        public MessageDigestCalculatingInputStream​(java.io.InputStream inputStream,
                                                   java.security.MessageDigest messageDigest)
        Creates a new instance, which calculates a signature on the given stream, using the given MessageDigest.
        Parameters:
        inputStream - the stream to calculate the message digest for
        messageDigest - the message digest to use
      • MessageDigestCalculatingInputStream

        @Deprecated
        public MessageDigestCalculatingInputStream​(java.io.InputStream inputStream,
                                                   java.lang.String algorithm)
                                            throws java.security.NoSuchAlgorithmException
        Creates a new instance, which calculates a signature on the given stream, using a MessageDigest with the given algorithm.
        Parameters:
        inputStream - the stream to calculate the message digest for
        algorithm - the name of the algorithm requested. See the MessageDigest section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard algorithm names.
        Throws:
        java.security.NoSuchAlgorithmException - if no Provider supports a MessageDigestSpi implementation for the specified algorithm.
    • Method Detail

      • getDefaultMessageDigest

        static java.security.MessageDigest getDefaultMessageDigest()
                                                            throws java.security.NoSuchAlgorithmException
        Gets a MessageDigest object that implements the default digest algorithm.
        Returns:
        a Message Digest object that implements the default algorithm.
        Throws:
        java.security.NoSuchAlgorithmException - if no Provider supports a MessageDigestSpi implementation.
        See Also:
        Provider
      • getMessageDigest

        public java.security.MessageDigest getMessageDigest()
        Gets the MessageDigest, which is being used for generating the checksum.

        Note: The checksum will only reflect the data, which has been read so far. This is probably not, what you expect. Make sure, that the complete data has been read, if that is what you want. The easiest way to do so is by invoking ObservableInputStream.consume().

        Returns:
        the message digest used