6

To verify my files have uploaded correctly, is there a tool to generate the Amazon Glacier Tree Hash SHA-256 for files locally?

zeroprobe
  • 181
  • 4

4 Answers4

6

boto has a utility function to do this.

Here's a wrapper script to turn it into a command line tool

#!/usr/bin/env python

import os
import sys
import argparse
import boto

from boto.glacier.utils import compute_hashes_from_fileobj

parser = argparse.ArgumentParser(description='compute amazon tree hashes of files')
parser.add_argument("--quiet", "-q", action='store_true')
parser.add_argument("filename", nargs='+')
args = parser.parse_args()

for filename in args.filename:
    with open(filename, 'r') as f:
        sha, tree = compute_hashes_from_fileobj(f)
        if args.quiet:
           print tree
        else:
            print filename + ":", tree
Lawrence D'Anna
  • 287
  • 2
  • 6
  • 10
2

Sorted, I made a quick Windows tool from Amazons own source to compute the hash.

https://mega.co.nz/#!HBMQ0ZSL!l0p0AamSpoFxKwDtJU03_uTi9t9hJ-6EVURmOSXSP3Y

zeroprobe
  • 181
  • 4
  • 1
    This is a nice simple solution that works well for Windows GUI. Would be nice if it was open-source though. – Jason Sep 21 '18 at 02:05
2

Glacier documentation provides a sample code to compute SHA256 tree hash.

I've built a Docker image to run this sample code. You can use it to compute SHA256 tree hash for multiple files:

docker run -it --rm -v `pwd`:/app ggarnier/glacier-sha256-tree-hash:latest <file1> <file2> ...

0

There is a bash script implementation using openssl here: https://github.com/numblr/glaciertools

user1587520
  • 101
  • 1