In bash, we can calculate the md5sum value of a file:
md5sum a_full_image-04.29-2024.bin
e95cfab84067098b1daf425f70416fcb md5sum a_full_image-04.29-2024.bin
AND/OR we can calculate the md5sum value of a specified region of the file:
dd bs=1 skip=$((0x76800)) count=$((0x5F000)) if=./a_full_image-04.29-2024.bin | md5sum
389120+0 records in
389120+0 records out
389120 bytes (389 kB, 380 KiB) copied, 0.547926 s, 710 kB/s
a371bea41b542f5ceb564be2a2a11f5e -
May I ask, in Python3, how to calculate the md5sum for a specified region (like using the dd command as above..)
I am new to Python. I generated the correct md5sum of specified files with the mmap, hashlib, etc. However, when it comes to the md5sum with a range, I still get stuck with the runtime error. At this point, I am not sure how to efficiently generate the md5sum of a partial file with correct syntax.
Thanks!
jfa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.