# Class: com.pnfsoftware.jeb.util.encoding.HashCalculator

Memory and CPU efficient way to compute message digests. 

 This class supersedes [Hash](Hash).

## Constructor: HashCalculator
- parameter: `in`, type: `java.io.InputStream`
- parameter: `flags`, type: `int`

Description: Create a calculator for the requested checksum and digest algorithms.
parameter: in: input stream to consume during [#compute()](#compute())
parameter: flags: bit mask composed of [#CRC32](#CRC32), [#ADLER32](#ADLER32), [#MD5](#MD5),            [#SHA1](#SHA1), and [#SHA256](#SHA256)

## Static Field: ADLER32
Type: `int`

Constant value: `2`
Description: Compute an Adler\-32 checksum.

## Static Field: CRC32
Type: `int`

Constant value: `1`
Description: Compute a CRC\-32 checksum.

## Static Field: MD5
Type: `int`

Constant value: `4`
Description: Compute an MD5 digest.

## Static Field: SHA1
Type: `int`

Constant value: `8`
Description: Compute a SHA\-1 digest.

## Static Field: SHA256
Type: `int`

Constant value: `16`
Description: Compute a SHA\-256 digest.

## Method: compute
- return type: `boolean`

Description: Compute the requested digests and stream size.
return: true on success, false if one of the requested digest algorithm is not available
throws: on stream IO error

## Method: getAdler32
- return type: `long`

Description: Get the computed Adler\-32 checksum.
return: Adler\-32 value

## Method: getCrc32
- return type: `long`

Description: Get the computed CRC\-32 checksum.
return: CRC\-32 value

## Method: getMd5
- return type: `byte[]`

Description: Get the computed MD5 digest.
return: digest bytes

## Method: getSha1
- return type: `byte[]`

Description: Get the computed SHA\-1 digest.
return: digest bytes

## Method: getSha256
- return type: `byte[]`

Description: Get the computed SHA\-256 digest.
return: digest bytes

## Method: getSize
- return type: `long`

Description: Get the number of bytes consumed during computation.
return: stream size in bytes

## Static Method: adler32
- parameter: `in`, type: `java.io.InputStream`
- return type: `java.lang.Long`

Description: Compute an Adler\-32 checksum for an input stream.
parameter: in: input stream to consume
return: checksum value, or null if reading failed

## Static Method: crc32
- parameter: `in`, type: `java.io.InputStream`
- return type: `java.lang.Long`

Description: Compute a CRC\-32 checksum for an input stream.
parameter: in: input stream to consume
return: checksum value, or null if reading failed

## Static Method: md5
- parameter: `in`, type: `java.io.InputStream`
- return type: `byte[]`

Description: Compute an MD5 digest for an input stream.
parameter: in: input stream to consume
return: digest bytes, or null if reading failed or the digest is unavailable

## Static Method: sha1
- parameter: `in`, type: `java.io.InputStream`
- return type: `byte[]`

Description: Compute a SHA\-1 digest for an input stream.
parameter: in: input stream to consume
return: digest bytes, or null if reading failed or the digest is unavailable

## Static Method: sha256
- parameter: `in`, type: `java.io.InputStream`
- return type: `byte[]`

Description: Compute a SHA\-256 digest for an input stream.
parameter: in: input stream to consume
return: digest bytes, or null if reading failed or the digest is unavailable

