fh-tool 2.3.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ include pyproject.toml
2
+ include README.md
3
+
4
+ recursive-include filehash_tool *.py
5
+ recursive-include tests *.py
6
+
7
+ global-exclude *.pyc
8
+ global-exclude __pycache__
9
+ global-exclude .mypy_cache
fh_tool-2.3.6/PKG-INFO ADDED
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.4
2
+ Name: fh-tool
3
+ Version: 2.3.6
4
+ Summary: 本CLI工具用于计算、存储、验证磁盘文件的hash值,可检查文件是否被篡改。
5
+ Author-email: Ma Lin <malincns@163.com>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://bitbucket.org/wjssz/filehash
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Topic :: System :: Archiving
11
+ Classifier: Topic :: System :: Archiving :: Backup
12
+ Classifier: Topic :: System :: Shells
13
+ Classifier: Topic :: Utilities
14
+ Classifier: Operating System :: Unix
15
+ Classifier: Operating System :: POSIX
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Requires-Python: >=3.7
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: colorama
21
+
22
+ This tool only provides Simplified Chinese user interface.
23
+
24
+ ### 简介
25
+
26
+ 本CLI工具用于计算、存储、验证磁盘文件的hash值,可检查文件是否被篡改。
27
+
28
+ 有以下功能:
29
+
30
+ - 将磁盘文件的**hash值**、**大小**、**路径**、**登记时间**、**数据库ID**保存到数据库的hash链中
31
+ - 验证数据库中的记录,检查记录的路径、hash值、大小
32
+ - 验证磁盘文件,将hash值、大小、路径与数据库中的记录对比
33
+ - 仅打印数据库中的记录
34
+ - 仅计算磁盘文件的hash值
35
+
36
+ 建议配置环境变量使用。目前大多数下载网站提供`sha256`值,因此默认使用`sha256`算法。
37
+
38
+ ### CLI命令
39
+
40
+ 路径使用[glob](https://docs.python.org/3/library/glob.html)语法:`*` `?` `[]` `**`
41
+
42
+ 🟢添加文件信息到数据库:
43
+ ```shell
44
+ filehash add 'E:\software\python-3.13.12-amd64.exe'
45
+ filehash a 'E:\software\*.exe'
46
+ filehash a 'E:\software\**\*.exe' # **遍历子目录
47
+ filehash a '*.exe' # 当前目录下所有.exe文件
48
+ filehash a '*' # 当前目录下所有文件
49
+ ```
50
+
51
+ 🟠验证数据库中的记录:
52
+ ```shell
53
+ # 如果磁盘文件已被删除,会提示文件不存在,但不会中止。
54
+ filehash verify_record '*\python*.exe'
55
+ filehash vr '*\software\*.exe'
56
+ filehash vr '*\software\**\*.exe'
57
+ filehash vr '*.exe' # 验证数据库中的所有.exe文件
58
+ filehash vr '*' # 验证数据库中的所有记录
59
+ ```
60
+
61
+ 🔵验证磁盘上的文件:
62
+ ```shell
63
+ # 如果数据库中没有该hash值、大小的数据,程序会报错、中止。
64
+ # 此功能可Windows/Linux双系统时使用
65
+ filehash verify_file 'E:\software\python-3.13.12-amd64.exe'
66
+ filehash vf 'E:\software\*.exe'
67
+ filehash vf 'E:\software\**\*.exe'
68
+ ```
69
+
70
+ 🟤在终端运行filehash,打印完整的帮助信息:
71
+ ```
72
+ PS E:\> filehash
73
+ usage: filehash [-h] [-m HASH_METH] [-n] [--db-dir DIR] [--backup-dir DIR] [--backup-size SIZE]
74
+ [CMD] [PATH]
75
+
76
+ 文件hash校验。版本: 2.3.6
77
+ https://pypi.org/project/filehash-tool
78
+
79
+ positional arguments:
80
+ CMD 命令
81
+ PATH 路径,使用glob语法,*表示所有文件,dir/**/*.exe遍历子目录。
82
+
83
+ options:
84
+ -h, --help show this help message and exit
85
+ -m, --hash-meth HASH_METH
86
+ 创建数据库时使用的hash算法,覆盖FILEHASH_HASH_METH环境变量。
87
+ -n, --no-space 打印hash时,不添加空格。
88
+ --db-dir DIR 数据库目录,覆盖FILEHASH_DB_DIR环境变量。
89
+ --backup-dir DIR 备份保存的数据库目录,覆盖FILEHASH_BACKUP_DIR环境变量。
90
+ --backup-size SIZE 备份保存的数据库数量,覆盖FILEHASH_BACKUP_SIZE环境变量。
91
+
92
+ 可用命令:
93
+ add/a 登记文件到数据库
94
+ verify_record/vr 验证数据库中的记录
95
+ print_record/pr 打印数据库中的记录
96
+ print_existing_record/per 打印数据库中尚存在的记录
97
+ verify_file/vf 验证磁盘文件
98
+ print_file/pf 计算文件hash值 (不加载数据库)
99
+ print_accumulated_hash 打印指定ID的累积hash
100
+
101
+ 保证存在的hash算法: blake2b, blake2s, md5, sha1, sha224, sha256, sha384,
102
+ sha3_224, sha3_256, sha3_384, sha3_512, sha512, shake_128, shake_256
103
+ 其它可用的hash算法: md5-sha1, ripemd160, sha512_224, sha512_256, sm3
104
+ 当前创建数据库使用的hash算法: sha256
105
+ ```
106
+
107
+ ### 更新日志
108
+
109
+ 2.3.0: 对数据库记录的glob语法:支持`**`遍历子目录,运行在Linux/macOS时不再区分大小写、可使用`/`或`\`匹配数据库记录的路径分隔符。
110
+
111
+ 2.2.0: 数据库向前不兼容。改变数据库格式,所有元素加入hash链。
@@ -0,0 +1,90 @@
1
+ This tool only provides Simplified Chinese user interface.
2
+
3
+ ### 简介
4
+
5
+ 本CLI工具用于计算、存储、验证磁盘文件的hash值,可检查文件是否被篡改。
6
+
7
+ 有以下功能:
8
+
9
+ - 将磁盘文件的**hash值**、**大小**、**路径**、**登记时间**、**数据库ID**保存到数据库的hash链中
10
+ - 验证数据库中的记录,检查记录的路径、hash值、大小
11
+ - 验证磁盘文件,将hash值、大小、路径与数据库中的记录对比
12
+ - 仅打印数据库中的记录
13
+ - 仅计算磁盘文件的hash值
14
+
15
+ 建议配置环境变量使用。目前大多数下载网站提供`sha256`值,因此默认使用`sha256`算法。
16
+
17
+ ### CLI命令
18
+
19
+ 路径使用[glob](https://docs.python.org/3/library/glob.html)语法:`*` `?` `[]` `**`
20
+
21
+ 🟢添加文件信息到数据库:
22
+ ```shell
23
+ filehash add 'E:\software\python-3.13.12-amd64.exe'
24
+ filehash a 'E:\software\*.exe'
25
+ filehash a 'E:\software\**\*.exe' # **遍历子目录
26
+ filehash a '*.exe' # 当前目录下所有.exe文件
27
+ filehash a '*' # 当前目录下所有文件
28
+ ```
29
+
30
+ 🟠验证数据库中的记录:
31
+ ```shell
32
+ # 如果磁盘文件已被删除,会提示文件不存在,但不会中止。
33
+ filehash verify_record '*\python*.exe'
34
+ filehash vr '*\software\*.exe'
35
+ filehash vr '*\software\**\*.exe'
36
+ filehash vr '*.exe' # 验证数据库中的所有.exe文件
37
+ filehash vr '*' # 验证数据库中的所有记录
38
+ ```
39
+
40
+ 🔵验证磁盘上的文件:
41
+ ```shell
42
+ # 如果数据库中没有该hash值、大小的数据,程序会报错、中止。
43
+ # 此功能可Windows/Linux双系统时使用
44
+ filehash verify_file 'E:\software\python-3.13.12-amd64.exe'
45
+ filehash vf 'E:\software\*.exe'
46
+ filehash vf 'E:\software\**\*.exe'
47
+ ```
48
+
49
+ 🟤在终端运行filehash,打印完整的帮助信息:
50
+ ```
51
+ PS E:\> filehash
52
+ usage: filehash [-h] [-m HASH_METH] [-n] [--db-dir DIR] [--backup-dir DIR] [--backup-size SIZE]
53
+ [CMD] [PATH]
54
+
55
+ 文件hash校验。版本: 2.3.6
56
+ https://pypi.org/project/filehash-tool
57
+
58
+ positional arguments:
59
+ CMD 命令
60
+ PATH 路径,使用glob语法,*表示所有文件,dir/**/*.exe遍历子目录。
61
+
62
+ options:
63
+ -h, --help show this help message and exit
64
+ -m, --hash-meth HASH_METH
65
+ 创建数据库时使用的hash算法,覆盖FILEHASH_HASH_METH环境变量。
66
+ -n, --no-space 打印hash时,不添加空格。
67
+ --db-dir DIR 数据库目录,覆盖FILEHASH_DB_DIR环境变量。
68
+ --backup-dir DIR 备份保存的数据库目录,覆盖FILEHASH_BACKUP_DIR环境变量。
69
+ --backup-size SIZE 备份保存的数据库数量,覆盖FILEHASH_BACKUP_SIZE环境变量。
70
+
71
+ 可用命令:
72
+ add/a 登记文件到数据库
73
+ verify_record/vr 验证数据库中的记录
74
+ print_record/pr 打印数据库中的记录
75
+ print_existing_record/per 打印数据库中尚存在的记录
76
+ verify_file/vf 验证磁盘文件
77
+ print_file/pf 计算文件hash值 (不加载数据库)
78
+ print_accumulated_hash 打印指定ID的累积hash
79
+
80
+ 保证存在的hash算法: blake2b, blake2s, md5, sha1, sha224, sha256, sha384,
81
+ sha3_224, sha3_256, sha3_384, sha3_512, sha512, shake_128, shake_256
82
+ 其它可用的hash算法: md5-sha1, ripemd160, sha512_224, sha512_256, sm3
83
+ 当前创建数据库使用的hash算法: sha256
84
+ ```
85
+
86
+ ### 更新日志
87
+
88
+ 2.3.0: 对数据库记录的glob语法:支持`**`遍历子目录,运行在Linux/macOS时不再区分大小写、可使用`/`或`\`匹配数据库记录的路径分隔符。
89
+
90
+ 2.2.0: 数据库向前不兼容。改变数据库格式,所有元素加入hash链。
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.4
2
+ Name: fh-tool
3
+ Version: 2.3.6
4
+ Summary: 本CLI工具用于计算、存储、验证磁盘文件的hash值,可检查文件是否被篡改。
5
+ Author-email: Ma Lin <malincns@163.com>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://bitbucket.org/wjssz/filehash
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Topic :: System :: Archiving
11
+ Classifier: Topic :: System :: Archiving :: Backup
12
+ Classifier: Topic :: System :: Shells
13
+ Classifier: Topic :: Utilities
14
+ Classifier: Operating System :: Unix
15
+ Classifier: Operating System :: POSIX
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Requires-Python: >=3.7
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: colorama
21
+
22
+ This tool only provides Simplified Chinese user interface.
23
+
24
+ ### 简介
25
+
26
+ 本CLI工具用于计算、存储、验证磁盘文件的hash值,可检查文件是否被篡改。
27
+
28
+ 有以下功能:
29
+
30
+ - 将磁盘文件的**hash值**、**大小**、**路径**、**登记时间**、**数据库ID**保存到数据库的hash链中
31
+ - 验证数据库中的记录,检查记录的路径、hash值、大小
32
+ - 验证磁盘文件,将hash值、大小、路径与数据库中的记录对比
33
+ - 仅打印数据库中的记录
34
+ - 仅计算磁盘文件的hash值
35
+
36
+ 建议配置环境变量使用。目前大多数下载网站提供`sha256`值,因此默认使用`sha256`算法。
37
+
38
+ ### CLI命令
39
+
40
+ 路径使用[glob](https://docs.python.org/3/library/glob.html)语法:`*` `?` `[]` `**`
41
+
42
+ 🟢添加文件信息到数据库:
43
+ ```shell
44
+ filehash add 'E:\software\python-3.13.12-amd64.exe'
45
+ filehash a 'E:\software\*.exe'
46
+ filehash a 'E:\software\**\*.exe' # **遍历子目录
47
+ filehash a '*.exe' # 当前目录下所有.exe文件
48
+ filehash a '*' # 当前目录下所有文件
49
+ ```
50
+
51
+ 🟠验证数据库中的记录:
52
+ ```shell
53
+ # 如果磁盘文件已被删除,会提示文件不存在,但不会中止。
54
+ filehash verify_record '*\python*.exe'
55
+ filehash vr '*\software\*.exe'
56
+ filehash vr '*\software\**\*.exe'
57
+ filehash vr '*.exe' # 验证数据库中的所有.exe文件
58
+ filehash vr '*' # 验证数据库中的所有记录
59
+ ```
60
+
61
+ 🔵验证磁盘上的文件:
62
+ ```shell
63
+ # 如果数据库中没有该hash值、大小的数据,程序会报错、中止。
64
+ # 此功能可Windows/Linux双系统时使用
65
+ filehash verify_file 'E:\software\python-3.13.12-amd64.exe'
66
+ filehash vf 'E:\software\*.exe'
67
+ filehash vf 'E:\software\**\*.exe'
68
+ ```
69
+
70
+ 🟤在终端运行filehash,打印完整的帮助信息:
71
+ ```
72
+ PS E:\> filehash
73
+ usage: filehash [-h] [-m HASH_METH] [-n] [--db-dir DIR] [--backup-dir DIR] [--backup-size SIZE]
74
+ [CMD] [PATH]
75
+
76
+ 文件hash校验。版本: 2.3.6
77
+ https://pypi.org/project/filehash-tool
78
+
79
+ positional arguments:
80
+ CMD 命令
81
+ PATH 路径,使用glob语法,*表示所有文件,dir/**/*.exe遍历子目录。
82
+
83
+ options:
84
+ -h, --help show this help message and exit
85
+ -m, --hash-meth HASH_METH
86
+ 创建数据库时使用的hash算法,覆盖FILEHASH_HASH_METH环境变量。
87
+ -n, --no-space 打印hash时,不添加空格。
88
+ --db-dir DIR 数据库目录,覆盖FILEHASH_DB_DIR环境变量。
89
+ --backup-dir DIR 备份保存的数据库目录,覆盖FILEHASH_BACKUP_DIR环境变量。
90
+ --backup-size SIZE 备份保存的数据库数量,覆盖FILEHASH_BACKUP_SIZE环境变量。
91
+
92
+ 可用命令:
93
+ add/a 登记文件到数据库
94
+ verify_record/vr 验证数据库中的记录
95
+ print_record/pr 打印数据库中的记录
96
+ print_existing_record/per 打印数据库中尚存在的记录
97
+ verify_file/vf 验证磁盘文件
98
+ print_file/pf 计算文件hash值 (不加载数据库)
99
+ print_accumulated_hash 打印指定ID的累积hash
100
+
101
+ 保证存在的hash算法: blake2b, blake2s, md5, sha1, sha224, sha256, sha384,
102
+ sha3_224, sha3_256, sha3_384, sha3_512, sha512, shake_128, shake_256
103
+ 其它可用的hash算法: md5-sha1, ripemd160, sha512_224, sha512_256, sm3
104
+ 当前创建数据库使用的hash算法: sha256
105
+ ```
106
+
107
+ ### 更新日志
108
+
109
+ 2.3.0: 对数据库记录的glob语法:支持`**`遍历子目录,运行在Linux/macOS时不再区分大小写、可使用`/`或`\`匹配数据库记录的路径分隔符。
110
+
111
+ 2.2.0: 数据库向前不兼容。改变数据库格式,所有元素加入hash链。
@@ -0,0 +1,14 @@
1
+ MANIFEST.in
2
+ README.md
3
+ pyproject.toml
4
+ fh_tool.egg-info/PKG-INFO
5
+ fh_tool.egg-info/SOURCES.txt
6
+ fh_tool.egg-info/dependency_links.txt
7
+ fh_tool.egg-info/entry_points.txt
8
+ fh_tool.egg-info/requires.txt
9
+ fh_tool.egg-info/top_level.txt
10
+ filehash_tool/__init__.py
11
+ filehash_tool/cr.py
12
+ filehash_tool/filehash.py
13
+ filehash_tool/globmatch.py
14
+ tests/test_globmatch.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ filehash = filehash_tool.filehash:main
@@ -0,0 +1 @@
1
+ colorama
@@ -0,0 +1 @@
1
+ filehash_tool
@@ -0,0 +1,4 @@
1
+ import os
2
+ import sys
3
+
4
+ sys.path.append(os.path.dirname(os.path.realpath(__file__)))
@@ -0,0 +1,59 @@
1
+ try:
2
+ import colorama
3
+ except ImportError:
4
+ colorama = None # type: ignore
5
+
6
+ __all__ = ('ENABLED',
7
+ 'Fore', 'Back',
8
+ 'BRIGHT', 'DIM', 'NORMAL', 'RESET_ALL',
9
+ 'p', 'cr_block')
10
+
11
+ ENABLED = (colorama is not None)
12
+
13
+ if colorama:
14
+ Fore = colorama.Fore
15
+ Back = colorama.Back
16
+
17
+ BRIGHT = colorama.Style.BRIGHT
18
+ DIM = colorama.Style.DIM
19
+ NORMAL = colorama.Style.NORMAL
20
+ RESET_ALL = colorama.Style.RESET_ALL
21
+ else:
22
+ class Colors:
23
+ def __getattribute__(self, _: str):
24
+ return ''
25
+
26
+ Fore = Back = Colors() # type: ignore
27
+
28
+ BRIGHT = ''
29
+ DIM = ''
30
+ NORMAL = ''
31
+ RESET_ALL = ''
32
+
33
+ def colored(obj, *args):
34
+ return ''.join((*args, str(obj), RESET_ALL))
35
+
36
+ def p(*args):
37
+ s = ''.join(args)
38
+ print(s)
39
+
40
+ class cr_block:
41
+ def __init__(self, prompt_pip=False):
42
+ if colorama:
43
+ if hasattr(colorama, 'just_fix_windows_console'):
44
+ # just_fix_windows_console() is available in colorama v0.4.6+
45
+ colorama.just_fix_windows_console()
46
+ else:
47
+ colorama.init()
48
+ elif prompt_pip:
49
+ print('安装colorama模块显示颜色文字信息: pip install colorama')
50
+
51
+ def close(self):
52
+ if colorama:
53
+ colorama.deinit()
54
+
55
+ def __enter__(self):
56
+ return self
57
+
58
+ def __exit__(self, exc_type, exc_value, traceback):
59
+ self.close()