Did this page help you?

   Yes   No   Tell us about it...

com.amazonaws.services.glacier
Class TreeHashGenerator

java.lang.Object
  extended by com.amazonaws.services.glacier.TreeHashGenerator

public class TreeHashGenerator
extends Object

Utility class for calculating tree hashes.

For more information on tree hashing, see http://en.wikipedia.org/wiki/Hash_tree.


Constructor Summary
TreeHashGenerator()
           
 
Method Summary
static 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeHashGenerator

public TreeHashGenerator()
Method Detail

calculateTreeHash

public static String calculateTreeHash(File file)
                                throws AmazonClientException
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

public static String calculateTreeHash(InputStream input)
                                throws AmazonClientException
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

public static String calculateTreeHash(List<byte[]> checksums)
                                throws AmazonClientException
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.


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.