java.lang.Object
com.perforce.p4java.impl.mapbased.rpc.func.helper.MD5Digester

public class MD5Digester extends 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.
  • Constructor Details

    • MD5Digester

      public MD5Digester() throws P4JavaError
      Throws:
      P4JavaError
    • MD5Digester

      public MD5Digester(@Nonnull int bufferSize)
  • Method Details

    • digestAsBytes

      public byte[] digestAsBytes()
    • digestFileAs32ByteHex

      @Nullable public String digestFileAs32ByteHex(@Nonnull 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 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 String digestFileAs32ByteHex(@Nonnull File file, @Nullable 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 String digestFileAs32ByteHex(@Nonnull File file, @Nullable 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 String digestFileAs32ByteHex(@Nonnull File file, @Nullable 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(String str)
    • update

      public void update(byte[] bytes)
    • getByteCount

      public long getByteCount()