Package com.amazonaws.services.glacier
Class TreeHashGenerator
java.lang.Object
com.amazonaws.services.glacier.TreeHashGenerator
Utility class for calculating tree hashes.
For more information on tree hashing, see http://en.wikipedia.org/wiki/Hash_tree.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
calculateTreeHash
(File file) Calculates a hex encoded binary hash using a tree hashing algorithm for the data in the specified file.static String
calculateTreeHash
(InputStream input) Calculates a hex encoded binary hash using a tree hashing algorithm for the data in the specified input stream.static String
calculateTreeHash
(List<byte[]> checksums) Returns the hex encoded binary tree hash for the individual checksums given.
-
Constructor Details
-
TreeHashGenerator
public TreeHashGenerator()
-
-
Method Details
-
calculateTreeHash
Calculates a hex encoded binary hash using a tree hashing algorithm for the data in the specified file.- Parameters:
file
- The file containing the data to hash.- Returns:
- The hex encoded binary tree hash for the data in the specified file.
- Throws:
AmazonClientException
- If any problems were encountered reading the data or computing the hash.
-
calculateTreeHash
Calculates a hex encoded binary hash using a tree hashing algorithm for the data in the specified input stream. The method will consume all the inputStream and close it when returned.- Parameters:
input
- The input stream containing the data to hash.- Returns:
- The hex encoded binary tree hash for the data in the specified input stream.
- Throws:
AmazonClientException
- If problems were encountered reading the data or calculating the hash.
-
calculateTreeHash
Returns the hex encoded binary tree hash for the individual checksums given. The sums are assumed to have been generated from sequential 1MB portions of a larger file, with the possible exception of the last part, which may be less than a full MB.- Returns:
- The combined hex encoded binary tree hash for the individual checksums specified.
- Throws:
AmazonClientException
- If problems were encountered reading the data or calculating the hash.
-