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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -