I'm trying to get the md5 in both php and python, but I'm not sure why the results are different, I have read in other questions about hashing strings but not files and I've also tried the echo -n but I get a syntax error.
Php:
<?php
echo 'MD5 file hash : ' . md5_file('https://cdn4.buysellads.net/uu/1/8026/1533152372-laptop_purple_graph.png');
?>
MD5 file hash : 5e81ca561d2c1e96b5e7a2e57244c8e5
python:
import hashlib
m=hashlib.md5('https://cdn4.buysellads.net/uu/1/8026/1533152372-laptop_purple_graph.png')
print('The MD5 checksum is',m.hexdigest())
MD5 file hash : 52e8e2e35519e8f6da474c5e1dc6d258
In Python snippet you are hashing the https://cdn4.buysellads.net/uu/1/8026/1533152372-laptop_purple_graph.png
string, which I guess is different from the contents.
You need to fetch url contents first and pass it to hashlib.md5
:
import urllib.request
import hashlib
contents = urllib.request.urlopen("https://cdn4.buysellads.net/uu/1/8026/1533152372-laptop_purple_graph.png").read()
m = hashlib.md5(content)
print('The MD5 checksum is',m.hexdigest())