Mercurial > codedump
comparison sfv.py @ 33:349c9636d8ca
Create sfv.py
committer: GitHub <noreply@github.com>
author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
---|---|
date | Thu, 17 Jun 2021 07:22:50 -0400 |
parents | |
children | 2aa9614cb39a |
comparison
equal
deleted
inserted
replaced
32:fdbafd3e86d9 | 33:349c9636d8ca |
---|---|
1 import os, sys, zlib | |
2 | |
3 def crc(filename): return "%X"%(zlib.crc32(open(filename,"rb").read()) & 0xFFFFFFFF) | |
4 | |
5 try: | |
6 temp = sys.argv[1] | |
7 except: | |
8 print("No file specified!") | |
9 sys.exit() | |
10 | |
11 f = open(sys.argv[1]) | |
12 lines = f.readlines() | |
13 f.close() | |
14 | |
15 for line in lines: | |
16 if not line[0] == ";": | |
17 crc32 = line.strip()[-8:] | |
18 name = line.strip()[:-8] | |
19 if crc(name).zfill(8) == crc32: | |
20 print(f"{name}: CRC hash match!") | |
21 else: | |
22 print(f"{name}: CRC hash does not match!") |