author Gregory Szorc <>
Wed, 28 Jan 2015 13:37:00 -0800
changeset 110546 6ed4715ca6580d572af43aa6ec2d2270fd77521f
parent 106844 d6deca9f6666164191d114e10fb4c80366aa3545
permissions -rw-r--r--
Close old release branch GECKO170_2012103106_RELBRANCH

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at

# This file contains miscellaneous utility functions that don't belong anywhere
# in particular.

import hashlib

def hash_file(path):
    """Hashes a file specified by the path given and returns the hex digest."""

    # If the hashing function changes, this may invalidate lots of cached data.
    # Don't change it lightly.
    h = hashlib.sha1()

    with open(path, 'rb') as fh:
        while True:
            data =

            if not len(data):


    return h.hexdigest()