changeset 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 fdbafd3e86d9
children e7fa57c4d3f7
files sfv.py
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sfv.py	Thu Jun 17 07:22:50 2021 -0400
@@ -0,0 +1,22 @@
+import os, sys, zlib
+
+def crc(filename): return "%X"%(zlib.crc32(open(filename,"rb").read()) & 0xFFFFFFFF)
+
+try:
+    temp = sys.argv[1]
+except:
+    print("No file specified!")
+    sys.exit()
+
+f = open(sys.argv[1])
+lines = f.readlines()
+f.close()
+
+for line in lines:
+    if not line[0] == ";":
+        crc32 = line.strip()[-8:]
+        name = line.strip()[:-8]
+        if crc(name).zfill(8) == crc32:
+            print(f"{name}: CRC hash match!")
+        else:
+            print(f"{name}: CRC hash does not match!")