md5sum

This is a simple md5 summer

#!/usr/bin/python

import hashlib, sys

def main():
    try:
        file = open(sys.argv[1], "rb")
        md5 = hashlib.md5()
        buffer = file.read(2 ** 20)
        while buffer:
            md5.update(buffer)
            buffer = file.read(2 ** 20)
        file.close()
        print md5.hexdigest()
    except:
        print "Usage: %s <filename>" % sys.argv[0]

if __name__ == '__main__':
main()
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s