Package com.adobe.testing.s3mock.util
Class HashUtil
- java.lang.Object
-
- com.adobe.testing.s3mock.util.HashUtil
-
public class HashUtil extends java.lang.ObjectA util-Class for the creation of Hashes.
-
-
Constructor Summary
Constructors Constructor Description HashUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetDigest(java.io.InputStream inputStream)Calculates a base64 MD5 Hash for the content of an inputStream.static java.lang.StringgetDigest(java.lang.String salt, java.io.InputStream inputStream)Calculates a base64 MD5 Hash for the content of an inputStream.
-
-
-
Method Detail
-
getDigest
public static java.lang.String getDigest(java.io.InputStream inputStream) throws java.security.NoSuchAlgorithmException, java.io.IOExceptionCalculates a base64 MD5 Hash 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 Hash, ETag, as part of the response Header to verify the validity of the transferred file.
- Parameters:
inputStream- the InputStream.- Returns:
- String Base64 MD5 Hash.
- Throws:
java.security.NoSuchAlgorithmException- if no md5 can be foundjava.io.IOException- if InputStream can't be read
-
getDigest
public static java.lang.String getDigest(java.lang.String salt, java.io.InputStream inputStream) throws java.security.NoSuchAlgorithmException, java.io.IOExceptionCalculates a base64 MD5 Hash 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 Hash, ETag, as part of the response Header to verify the validity of the transferred file. For encrypted uploads, the returned hash may not be the same as the local client hash value.
- Parameters:
salt- Optional salt to add to be digested, for simulating encryption dependent hashing.inputStream- the InputStream.- Returns:
- String Base64 MD5 Hash.
- Throws:
java.security.NoSuchAlgorithmException- if no md5 can be found.java.io.IOException- if InputStream can't be read.
-
-