ubuntu - md5sum of a file without file name assigning to a variable in python -


i'm trying assign md5 sum of file (in ubuntu) variable(any) in python script below

alist=subprocess.check_output(["md5sum",filename]) 

i want assign sum variable used below code it's not working

alist=subprocess.check_output(["md5sum",filename," | awk '{print $1}'"]) 

please me find out solution

thanks in advance

rather shelling out perform md5sum, use python's inbuilt hashlib.md5 implementation:

import hashlib  open(filename, 'rb') f:     hexdigest = hashlib.md5(f.read()).hexdigest()     print(hexdigest) 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -