How to generate Amazon Glacier SHA-256 Tree Hash for a file locally?
To verify my files have uploaded correctly, is there a tool to generate the Amazon Glacier Tree Hash SHA-256 for files locally?
Solution 1:
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
Solution 2:
Sorted, I made a quick Windows tool from Amazons own source to compute the hash.
https://mega.co.nz/#!HBMQ0ZSL!l0p0AamSpoFxKwDtJU03_uTi9t9hJ-6EVURmOSXSP3Y
Solution 3:
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> ...