File: cdrom_md5.py

package info (click to toggle)
game-data-packager 87
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 33,392 kB
  • sloc: python: 15,387; sh: 704; ansic: 95; makefile: 50
file content (22 lines) | stat: -rwxr-xr-x 470 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/python3
# encoding=utf-8
#
# Copyright © 2016 Alexandre Detiste <alexandre@detiste.be>
# SPDX-License-Identifier: GPL-2.0-or-later

import hashlib
import sys

CDROM_SECTOR = 2048

if len(sys.argv) != 2:
    exit('Usage: cdrom_md5.py <file>')

with open(sys.argv[1], 'rb') as f:
    while True:
        blob = f.read(CDROM_SECTOR)
        if not blob:
            break
        md5 = hashlib.new('md5')
        md5.update(blob)
        print(md5.hexdigest())