Package fr.gouv.vitam.common.digest
Class Digest
java.lang.Object
fr.gouv.vitam.common.digest.Digest
Digest implementation
-
Constructor Summary
ConstructorDescriptionDigest
(DigestType algo) Create one DigestLightDigest
(String digest, DigestType algo) Create one DigestLight from parameter -
Method Summary
Modifier and TypeMethodDescriptionfinal byte[]
digest()
static Digest
digest
(File in, DigestType algo) static Digest
digest
(InputStream in, DigestType algo) final String
digest64()
final String
final boolean
final boolean
equalsWithType
(byte[] digest, DigestType algo) final boolean
equalsWithType
(String digest, DigestType algo) getDigestInputStream
(InputStream inputStream) Will update the Digest while the returned InputStream will be readgetDigestOutputStream
(OutputStream outputStream) Will update the Digest while the returned OutputStream will be readfinal int
hashCode()
final Digest
reset()
Reset the DigestLightfinal String
toString()
final DigestType
type()
final Digest
update
(byte[] bytes) final Digest
update
(byte[] bytes, int offset, int length) final Digest
final Digest
final Digest
update
(InputStream inputStream) final Digest
update
(InputStream inputStream, int chunkSize) final Digest
update
(InputStream inputStream, int chunkSize, long limit) final Digest
final Digest
update
(ByteBuffer buffer) final Digest
update
(FileChannel fileChannelInputStream) final Digest
update
(FileChannel fileChannelInputStream, long start, int chunkSize, long limit)
-
Constructor Details
-
Digest
Create one DigestLight- Parameters:
algo
- the algorithm to use- Throws:
IllegalArgumentException
- if null or unknown algorithm
-
Digest
Create one DigestLight from parameter- Parameters:
digest
- as String to createalgo
- the algorithm to use- Throws:
IllegalArgumentException
- if null or unknown algorithm or if digest is null or empty
-
-
Method Details
-
type
- Returns:
- the associated digest type
-
update
- Parameters:
bytes
- the bytes from which to update- Returns:
- this
- Throws:
IllegalArgumentException
- if bytes null
-
update
- Parameters:
bytes
- the bytes from which to updateoffset
- the offset positionlength
- the length- Returns:
- this
- Throws:
IllegalArgumentException
- if bytes null, offset < 0, length < 0
-
update
- Parameters:
buffer
- for updating Digest- Returns:
- this
- Throws:
IllegalArgumentException
- if buffer null
-
update
- Parameters:
value
- the String value from which to update- Returns:
- this
- Throws:
IllegalArgumentException
- value null
-
update
- Parameters:
in
- the file from which to update- Returns:
- this
- Throws:
IOException
- if any IO error occursIllegalArgumentException
- in null
-
update
- Parameters:
in
- the file from which to updatestart
- the position to startlimit
- if less than 0, means all- Returns:
- this
- Throws:
IOException
- if any IO error occursIllegalArgumentException
- in null, start < 0
-
update
- Parameters:
inputStream
- the inputstream from which to update using default chunksize- Returns:
- this
- Throws:
IOException
- if any IO error occursIllegalArgumentException
- inputstream null
-
update
- Parameters:
inputStream
- the inputstream from which to updatechunkSize
- the chunksize to use- Returns:
- this
- Throws:
IOException
- if any IO error occursIllegalArgumentException
- inputstream null, chunksize < 1
-
update
- Parameters:
inputStream
- the inputstream from which to updatechunkSize
- the chunksize to uselimit
- if less than 0, means all- Returns:
- this
- Throws:
IOException
- if any IO error occursIllegalArgumentException
- inputstream null, chunksize < 1
-
update
- Parameters:
fileChannelInputStream
- the FileChannel inputstream from which to update- Returns:
- this
- Throws:
IOException
- if any IO error occursIllegalArgumentException
- fileChannelIinputStream null
-
update
public final Digest update(FileChannel fileChannelInputStream, long start, int chunkSize, long limit) throws IOException - Parameters:
fileChannelInputStream
- the FileChannel inputstream from which to updatestart
- the position to startchunkSize
- the chunksize to uselimit
- if less than 0, means all- Returns:
- this
- Throws:
IOException
- if any IO error occursIllegalArgumentException
- fileChannelIinputStream null, start < 0, chunksize < 1
-
getDigestInputStream
Will update the Digest while the returned InputStream will be read- Parameters:
inputStream
- from which the data to digest will be done- Returns:
- the new InputStream to use instead of the given one as parameter
-
getDigestOutputStream
Will update the Digest while the returned OutputStream will be read- Parameters:
outputStream
- to which the data to digest will be written- Returns:
- the new OutputStream to use instead of the given one as parameter
-
reset
Reset the DigestLight- Returns:
- this
-
digest
public final byte[] digest()- Returns:
- the digest
-
digestHex
- Returns:
- the digest in Base16 format
-
digest64
- Returns:
- the digest in Base64 format
-
toString
-
equals
-
hashCode
public final int hashCode() -
equalsWithType
- Parameters:
digest
- the digest to compare toalgo
- the associated algorithm- Returns:
- True if the 2 digests are of the same type and same value
-
equalsWithType
- Parameters:
digest
- the digest in byte to usealgo
- the associated algorithm- Returns:
- True if the 2 digests are of the same type and same value
-
digest
- Parameters:
in
- the inputstream from which the digest will be computedalgo
- the algorithm to use- Returns:
- the digest for this inputStream
- Throws:
IOException
- if any IO error occursIllegalArgumentException
- in or algo null
-
digest
- Parameters:
in
- the file from which the digest will be computedalgo
- the algorithm to use- Returns:
- the digest for this File
- Throws:
IOException
- if any IO error occursIllegalArgumentException
- in or algo null
-