com.perforce.p4java.impl.mapbased.rpc.func.helper
Class MD5Digester

java.lang.Object
  extended by 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.


Field Summary
static String DIGEST_TYPE
           
 
Constructor Summary
MD5Digester()
           
 
Method Summary
 String digestAs32ByteHex()
          Return the finalised digest as a 32 byte hex string.
 byte[] digestAsBytes()
           
 String digestFileAs32ByteHex(File file)
          Return the results of digesting an arbitrary file with this digester.
 String digestFileAs32ByteHex(File file, Charset charset)
          Return the results of digesting an arbitrary file with this digester.
 String digestFileAs32ByteHex(File file, Charset charset, boolean convertLineEndings)
          Return the results of digesting an arbitrary file with this digester.
 String digestFileAs32ByteHex(File file, Charset charset, boolean convertLineEndings, 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(ByteBuffer byteBuf)
          NOTE: side effects!!
 void update(String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIGEST_TYPE

public static final String DIGEST_TYPE
See Also:
Constant Field Values
Constructor Detail

MD5Digester

public MD5Digester()
Method Detail

reset

public void reset()

update

public void update(String str)

update

public void update(byte[] bytes)

update

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

update

public void update(ByteBuffer byteBuf)
NOTE: side effects!!


digestAsBytes

public byte[] digestAsBytes()

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...


digestFileAs32ByteHex

public String digestFileAs32ByteHex(File file,
                                    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 -
charset -
Returns:
- computed digest or null if computation failed

digestFileAs32ByteHex

public String digestFileAs32ByteHex(File file,
                                    Charset charset,
                                    boolean convertLineEndings)
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 -
charset -
convertLineEndings -
Returns:
- computed digest or null if computation failed

digestFileAs32ByteHex

public String digestFileAs32ByteHex(File file,
                                    Charset charset,
                                    boolean convertLineEndings,
                                    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 -
charset -
convertLineEndings -
clientLineEnding -
Returns:
- computed digest or null if computation failed

digestFileAs32ByteHex

public String digestFileAs32ByteHex(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 -
Returns:
- computed digest or null if computation failed


Copyright © 2015 Perforce Software. All Rights Reserved.