Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
rt-framework / rt / lib / utils / rt-filemd5
Size: Mime:
#! /usr/bin/env python
#
# Copyright (C) 2016 Rolf Neugebauer <rolf.neugebauer@docker.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#

"""Generate the MD5 digest of a file"""

import sys
import hashlib

# Read file in chunks
CHUNK_SIZE = 64 * 1024


def usage(ret):
    sys.stderr.write('Usage: %s <filename>\n' % sys.argv[0])
    sys.exit(ret)
    return


if not len(sys.argv) == 2:
    usage(-1)

h = hashlib.md5()
with open(sys.argv[1], "rb") as f:
    for c in iter(lambda: f.read(4096), b""):
        h.update(c)

print (h.hexdigest())