mirror of
https://github.com/JDM170/file_hash_checker
synced 2025-12-10 16:17:18 +07:00
Add files via upload
This commit is contained in:
3
build.bat
Normal file
3
build.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
python setup.py build
|
||||
pyinstaller build.spec --upx-dir=upx\
|
||||
40
build.spec
Normal file
40
build.spec
Normal file
@@ -0,0 +1,40 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
|
||||
block_cipher = None
|
||||
|
||||
|
||||
a = Analysis(['main.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False)
|
||||
pyz = PYZ(a.pure, a.zipped_data,
|
||||
cipher=block_cipher)
|
||||
|
||||
exe = EXE(pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='File hash checker',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=True,
|
||||
disable_windowed_traceback=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None)
|
||||
61
main.py
Normal file
61
main.py
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
hash_chunk_size = 65536
|
||||
|
||||
from sys import exit
|
||||
from hashlib import md5
|
||||
from os.path import getsize
|
||||
from progress.bar import IncrementalBar
|
||||
|
||||
|
||||
def check_hash_file(fn):
|
||||
try:
|
||||
with open(fn, "r") as f:
|
||||
fdata = f.read()
|
||||
fdata = fdata.split(" *")
|
||||
return fdata[0]
|
||||
except FileNotFoundError:
|
||||
return fn
|
||||
|
||||
|
||||
def check_file_exists(fn):
|
||||
try:
|
||||
open(fn, "rb").close()
|
||||
return True
|
||||
except FileNotFoundError:
|
||||
print(" ! File not found")
|
||||
return False
|
||||
except:
|
||||
print(" ! Unknown error")
|
||||
return False
|
||||
|
||||
|
||||
def generate_md5(fn):
|
||||
if check_file_exists(fn):
|
||||
hash_md5 = md5()
|
||||
with open(fn, "rb") as f:
|
||||
bar = IncrementalBar(" Comparing...", max=int(getsize(fn) / hash_chunk_size), suffix='%(percent)d%%')
|
||||
for chunk in iter(lambda: f.read(hash_chunk_size), b""):
|
||||
hash_md5.update(chunk)
|
||||
bar.next()
|
||||
bar.finish()
|
||||
return hash_md5.hexdigest()
|
||||
return False
|
||||
|
||||
|
||||
def input_files():
|
||||
file1 = str(input("\n Input first file: "))
|
||||
file2 = str(input(" Input hash sum: "))
|
||||
if (file1 != "") and (file2 != ""):
|
||||
print("\n Equals?:", generate_md5(file1) == check_hash_file(file2), "\n")
|
||||
input_files()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
input_files()
|
||||
except KeyboardInterrupt:
|
||||
if input("\n Stop comparing? (y/n): ").lower() == "y":
|
||||
exit()
|
||||
input_files()
|
||||
37
setup.py
Normal file
37
setup.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from sys import platform
|
||||
from cx_Freeze import setup, Executable
|
||||
|
||||
executables = [
|
||||
Executable('program.py', targetName='prog.exe', base='Console')
|
||||
]
|
||||
|
||||
excludes = [
|
||||
'html', 'pydoc_data', 'unittest', 'xml', 'pwd', 'shlex', 'platform', 'webbrowser', 'pydoc', 'tty',
|
||||
'inspect', 'doctest', 'plistlib', 'subprocess', 'bz2', '_strptime', 'dummy_threading'
|
||||
]
|
||||
|
||||
zip_include_packages = [
|
||||
'collections', 'encodings', 'importlib', 'codecs', 'abc', 'sys',
|
||||
'hashlib', 'logging', 'unicodedata', 'progress'
|
||||
]
|
||||
|
||||
options = {
|
||||
'build_exe': {
|
||||
'excludes': excludes,
|
||||
'include_msvcr': True,
|
||||
'build_exe': 'cx_build',
|
||||
'zip_include_packages': zip_include_packages,
|
||||
}
|
||||
}
|
||||
|
||||
setup(
|
||||
name='File hash checker',
|
||||
version='0.1',
|
||||
#description='',
|
||||
executables=executables,
|
||||
options=options,
|
||||
requires=['hashlib', 'progress'],
|
||||
)
|
||||
Reference in New Issue
Block a user