Tool to compute SHA256 Tree Hash

5,222

After a bit more research, it looks like the concept of SHA-256 Tree Hash is something specific to Amazon Glacier, hence the difficulty to find any tool that supports it.

However, the Glacier documentation provides sample code to compute the hash, in Java and C#. Both compile into a command-line tool that computes the hash of the file given as an argument.

I just copied and pasted the C# code in the free Visual C# 2010 Express, compiled it, and I now have the command line tool I was looking for!

Share:
5,222
BenMorel
Author by

BenMorel

Author of Brick, a collection of open-source libraries for PHP applications: brick/math : an arbitrary-precision arithmetic library brick/money : a money and currency library brick/date-time : a date and time library brick/phonenumber : a phone number library brick/geo : a GIS geometry library brick/varexporter : a powerful alternative to var_export() ... and a few others.

Updated on September 18, 2022

Comments

  • BenMorel
    BenMorel over 1 year

    I've started using AWS Glacier, and noticed that it hashes the files using an algorithm called SHA-256 Tree Hash.

    To my surprise, this algorithm is different from SHA-256, so I can't use the tools I'm used to, to compare hashes and verify file integrity.

    Do you know a Windows tool, if possible integrated in the context menu, to compute the SHA-256 Tree Hash of a file?

    I'd also accept a Linux command-line tool, as a second choice :-)

    • DerfK
      DerfK over 11 years
      stackoverflow.com/questions/12058011/… explains what the SHA-256 Tree Hash is, but I don't know of any ready-made programs to do it.
    • Magellan
      Magellan over 11 years
      Questions that are effectively requests for product recommendations are off-topic for ServerFault. Please see: blog.stackoverflow.com/2010/11/qa-is-hard-lets-go-shopping
    • BenMorel
      BenMorel over 11 years
      @Adrian Thanks. But I've read that link, and can't see how it relates to my question. I'm not asking for the best tool to do the job, but instead if such a tool exists, and where to find it. I've found the answer to my question anyway, so no worries.
    • Magellan
      Magellan over 11 years
      The 'if exists and where to find it' part is what makes it a 'Shopping' question. If you have any questions about how that works, I definitely encourage you to visit Meta.Serverfault and inquire there.
    • Philip
      Philip over 11 years
      If a question distills to "I'm looking for $PRODUCT with $FEATURES" then it's a shopping Question. This one is "I'm looking for a utility with SHA-256 Tree Hash capabilities."
    • BenMorel
      BenMorel over 11 years
      Say I got your point, how/where should I have asked this question, then?
    • Dan Ciborowski - MSFT
      Dan Ciborowski - MSFT about 9 years
      Years later... I am proposing a place for this type of question, and referencing this question as a good question without a home... area51.stackexchange.com/proposals/82757/…
  • obaqueiro
    obaqueiro over 9 years
    Just for future reference. There's also a Ruby gem that can be installed and used to calculate the SHA2-256 treehash sum: github.com/erichmenge/treehash
  • David Ehrmann
    David Ehrmann about 9 years
    Isn't the AWS tree hash just a Merkle tree with SHA-256?
  • Guilherme Garnier
    Guilherme Garnier almost 7 years
    I've created a Docker image to run this sample code: hub.docker.com/r/ggarnier/glacier-sha256-tree-hash
  • user1587520
    user1587520 almost 6 years
    Here a pure bash implementation using openssl: github.com/tkb-/glaciertools
  • Jason
    Jason over 5 years
    This question is a duplicate of: serverfault.com/questions/643222/… Follow the above link for more detailed and up-to-date answers
  • BenMorel
    BenMorel over 5 years
    @Jason The linked question is actually a duplicate of this one, coming 2 years later. It's actually funny that it has not been closed as well as a "product recommendation" as they like to call it.