Obtaining MD5 hash value from online image / movie using Python
Question: I'm currently looking to put together a quick script using Python 2.x to try
and obtain the MD5 hash value of a number of images and movies on specific
websites. I have noted on the w3.org website that the HTTP/1.1 protocol does
offer an option within the content field to access the MD5 value but I'm
wondering if this has to be set by the website admin? My script is as below:-

    
    
    import httplib
    c = httplib.HTTPConnection("www.samplesite.com")
    c.request("HEAD", "/sampleimage.jpg")
    r = c.getresponse()
    res = r.getheaders()
    print res
    

I have a feeling I need to edit 'HEAD' or possibly r.getheaders but I'm just
not sure what to replace them with.

Any suggestions? As said, I'm just looking to point at an image and to then
capture the MD5 hash value of the said image / movie. Ideally I don't want to
have to download the image / movie to save bandwidth hence why I'm trying to
do it this way.

Thanks in advance


Answer: Yes, it's rare that servers will actually respond to requests with an MD5
header. You _can_ check for that, but in most cases, you'll actually need to
download the video or image, unfortunately.

(At least [`hashlib`](http://docs.python.org/2/library/hashlib.html#module-
hashlib) is simple!)

