Class MD5Digester


  • public class MD5Digester
    extends java.lang.Object
    Provide MD5 digest methods for the rest of the RPC implementation. Basically just a wrapper around the normal Java stuff, with a useful added method to finalise the digest as a hex string.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String digestAs32ByteHex()
      Return the finalised digest as a 32 byte hex string.
      byte[] digestAsBytes()  
      java.lang.String digestFileAs32ByteHex​(java.io.File file)
      Return the results of digesting an arbitrary file with this digester.
      java.lang.String digestFileAs32ByteHex​(java.io.File file, java.nio.charset.Charset charset)
      Return the results of digesting an arbitrary file with this digester.
      java.lang.String digestFileAs32ByteHex​(java.io.File file, java.nio.charset.Charset charset, boolean doesNeedConvertLineEndings)
      Return the results of digesting an arbitrary file with this digester.
      java.lang.String digestFileAs32ByteHex​(java.io.File file, java.nio.charset.Charset charset, boolean isRequireLineEndingConvert, ClientLineEnding clientLineEnding)
      Return the results of digesting an arbitrary file with this digester and a specific client line ending.
      void reset()  
      void update​(byte[] bytes)  
      void update​(byte[] bytes, int off, int len)  
      void update​(java.lang.String str)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MD5Digester

        public MD5Digester​(@Nonnull
                           int bufferSize)
    • Method Detail

      • digestAsBytes

        public byte[] digestAsBytes()
      • digestFileAs32ByteHex

        @Nullable
        public java.lang.String digestFileAs32ByteHex​(@Nonnull
                                                      java.io.File file)
        Return the results of digesting an arbitrary file with this digester.

        Returns null if it can't read or digest the file for whatever reason; otherwise the finalized digest is returned as a 32 byte hex string.

        Parameters:
        file - file
        Returns:
        - computed digest or null if computation failed
      • reset

        public void reset()
      • update

        public void update​(byte[] bytes,
                           int off,
                           int len)
      • digestAs32ByteHex

        public java.lang.String digestAs32ByteHex()
        Return the finalised digest as a 32 byte hex string. It's important elsewhere and in the server that the string be exactly 32 bytes long, so we stitch it up if possible to make it that long...
        Returns:
        digest
      • digestFileAs32ByteHex

        @Nullable
        public java.lang.String digestFileAs32ByteHex​(@Nonnull
                                                      java.io.File file,
                                                      @Nullable
                                                      java.nio.charset.Charset charset)
        Return the results of digesting an arbitrary file with this digester.

        Returns null if it can't read or digest the file for whatever reason; otherwise the finalized digest is returned as a 32 byte hex string.

        Parameters:
        file - file
        charset - charset
        Returns:
        - computed digest or null if computation failed
      • digestFileAs32ByteHex

        @Nullable
        public java.lang.String digestFileAs32ByteHex​(@Nonnull
                                                      java.io.File file,
                                                      @Nullable
                                                      java.nio.charset.Charset charset,
                                                      boolean doesNeedConvertLineEndings)
        Return the results of digesting an arbitrary file with this digester.

        Returns null if it can't read or digest the file for whatever reason; otherwise the finalized digest is returned as a 32 byte hex string.

        Parameters:
        file - file
        charset - charset
        doesNeedConvertLineEndings - doesNeedConvertLineEndings
        Returns:
        - computed digest or null if computation failed
      • digestFileAs32ByteHex

        @Nullable
        public java.lang.String digestFileAs32ByteHex​(@Nonnull
                                                      java.io.File file,
                                                      @Nullable
                                                      java.nio.charset.Charset charset,
                                                      boolean isRequireLineEndingConvert,
                                                      @Nullable
                                                      ClientLineEnding clientLineEnding)
        Return the results of digesting an arbitrary file with this digester and a specific client line ending.

        Returns null if it can't read or digest the file for whatever reason; otherwise the finalized digest is returned as a 32 byte hex string.

        Parameters:
        file - file
        charset - charset
        isRequireLineEndingConvert - isRequireLineEndingConvert
        clientLineEnding - clientLineEnding
        Returns:
        - computed digest or null if computation failed
      • update

        public void update​(java.lang.String str)
      • update

        public void update​(byte[] bytes)