Class DigestUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringbase64Digest(byte[] binaryData) static Stringbase64Digest(InputStream inputStream) Calculates a base64 MD5 digest for the content of an inputStream.static Stringbase64Digest(String salt, InputStream inputStream) Calculates a base64 MD5 digest for the content of an inputStream.static StringhexDigest(byte[] bytes) static Stringstatic StringhexDigest(InputStream inputStream) Calculates a hex encoded MD5 digest for the content of an inputStream.static Stringstatic StringhexDigest(String salt, InputStream inputStream) Calculates a hex encoded MD5 digest for the content of an inputStream.static StringhexDigestMultipart(List<Path> paths) Calculates a hex encoded MD5 digest for the contents of a list of paths.
-
Constructor Details
-
DigestUtil
public DigestUtil()
-
-
Method Details
-
hexDigestMultipart
Calculates a hex encoded MD5 digest for the contents of a list of paths. This is a special case that emulates how AWS calculates the MD5 Checksums of the parts of a Multipart upload: Stackoverflow Quote from Stackoverflow: Say you uploaded a 14MB file to a bucket without server-side encryption, and your part size is 5MB. Calculate 3 MD5 checksums corresponding to each part, i.e. the checksum of the first 5MB, the second 5MB, and the last 4MB. Then take the checksum of their concatenation. MD5 checksums are often printed as hex representations of binary data, so make sure you take the MD5 of the decoded binary concatenation, not of the ASCII or UTF-8 encoded concatenation. When that's done, add a hyphen and the number of parts to get the ETag.- Parameters:
paths- the list of paths.- Returns:
- A special hex digest that is used for files uploaded in parts.
- Throws:
IOException- if a path could not be accessed.
-
hexDigest
-
hexDigest
-
hexDigest
-
hexDigest
Calculates a hex encoded MD5 digest for the content of an inputStream.Mainly used for comparison of files. E.g. After Putting a File to the Server, the Amazon S3-Client expects a hex encoded MD5 digest as the ETag, as part of the response Header to verify the validity of the transferred file.
- Parameters:
inputStream- the InputStream.- Returns:
- String Hex MD5 digest.
-
hexDigest
Calculates a hex encoded MD5 digest for the content of an inputStream.Mainly used for comparison of files. E.g. After Putting a File to the Server, the Amazon S3-Client expects a hex encoded MD5 digest as the ETag, as part of the response Header to verify the validity of the transferred file. For encrypted uploads, the returned digest may not be the same as the local client digest value.
- Parameters:
salt- Optional salt to add to be digested, for simulating encryption dependent digest.inputStream- the InputStream.- Returns:
- String Hex MD5 digest.
-
base64Digest
Calculates a base64 MD5 digest for the content of an inputStream.Mainly used for comparison of files. E.g. After Putting a File to the Server, the Amazon S3-Client expects a base64 MD5 digest, ETag, as part of the response Header to verify the validity of the transferred file.
- Parameters:
inputStream- the InputStream.- Returns:
- String Base64 MD5 digest.
-
base64Digest
Calculates a base64 MD5 digest for the content of an inputStream.Mainly used for comparison of files. E.g. After Putting a File to the Server, the Amazon S3-Client expects a base64 MD5 digest, ETag, as part of the response Header to verify the validity of the transferred file. For encrypted uploads, the returned digest may not be the same as the local client digest value.
- Parameters:
salt- Optional salt to add to be digested, for simulating encryption dependent digest.inputStream- the InputStream.- Returns:
- String Base64 MD5 digest.
-
base64Digest
-