PyHashKit 0.1.0__tar.gz → 0.2.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyHashKit
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A lightweight Python library for hashing text and files using multiple cryptographic algorithms.
5
5
  Home-page: https://github.com/Fmasterpro27/PyHashKit
6
6
  Author: fmasterpro27
@@ -30,7 +30,7 @@ Dynamic: requires-python
30
30
 
31
31
  # PyHashKit
32
32
 
33
- > A lightweight Python library for hashing text and files using multiple cryptographic algorithms.
33
+ > A lightweight Python library and CLI for hashing text and files using multiple cryptographic algorithms.
34
34
 
35
35
  [![PyPI version](https://img.shields.io/pypi/v/pyhashkit.svg)](https://pypi.org/project/pyhashkit/)
36
36
  [![Python versions](https://img.shields.io/pypi/pyversions/pyhashkit.svg)](https://pypi.org/project/pyhashkit/)
@@ -42,6 +42,7 @@ Dynamic: requires-python
42
42
 
43
43
  - 🔐 Hash text strings
44
44
  - 📄 Hash files of any size
45
+ - 💻 Built-in CLI support
45
46
  - ⚡ Supports multiple algorithms
46
47
  - 📦 Zero dependencies
47
48
  - 🐍 Python 3.8+
@@ -49,9 +50,17 @@ Dynamic: requires-python
49
50
 
50
51
  ---
51
52
 
53
+ ## Why PyHashKit?
54
+
55
+ PyHashKit provides a simple and beginner-friendly interface for Python's built-in hashing functionality.
56
+
57
+ Instead of manually working with `hashlib`, you can hash text and files with a single function call or directly from the command line.
58
+
59
+ ---
60
+
52
61
  ## Supported Algorithms
53
62
 
54
- PyHashKit supports any algorithm available through Python's built-in `hashlib`.
63
+ PyHashKit supports most algorithms available through Python's built-in `hashlib`.
55
64
 
56
65
  Common examples:
57
66
 
@@ -68,6 +77,15 @@ Common examples:
68
77
  - BLAKE2b
69
78
  - BLAKE2s
70
79
 
80
+ ### Not Supported
81
+
82
+ The following algorithms are currently not supported:
83
+
84
+ - SHAKE-128 (`shake_128`)
85
+ - SHAKE-256 (`shake_256`)
86
+
87
+ These algorithms require a custom digest length and are intentionally excluded to keep the API simple and consistent.
88
+
71
89
  ---
72
90
 
73
91
  ## Installation
@@ -89,9 +107,76 @@ print(hash_file("example.txt"))
89
107
 
90
108
  ---
91
109
 
92
- ## Python API
110
+ # Command Line Interface (CLI)
111
+
112
+ PyHashKit includes a built-in command-line interface for hashing text and files directly from your terminal.
113
+
114
+ ## Available Commands
115
+
116
+ ```text
117
+ text Hash a text string
118
+ file Hash a file
119
+ commands Show all commands
120
+ ```
121
+
122
+ ## Flags
123
+
124
+ ```text
125
+ -v, -V, --version
126
+ Show version information
127
+ ```
128
+
129
+ ## Options
93
130
 
94
- ### Hash Text
131
+ ```text
132
+ -a, --algorithm
133
+ Specify hashing algorithm
134
+ (default: sha256)
135
+ ```
136
+
137
+ ## Examples
138
+
139
+ Hash text:
140
+
141
+ ```bash
142
+ pyhashkit text "Hello World"
143
+ ```
144
+
145
+ Hash text using MD5:
146
+
147
+ ```bash
148
+ pyhashkit text "Hello World" -a md5
149
+ ```
150
+
151
+ Hash a file:
152
+
153
+ ```bash
154
+ pyhashkit file example.txt
155
+ ```
156
+
157
+ Hash a file using SHA-512:
158
+
159
+ ```bash
160
+ pyhashkit file example.txt -a sha512
161
+ ```
162
+
163
+ Show version information:
164
+
165
+ ```bash
166
+ pyhashkit -v
167
+ ```
168
+
169
+ Show all available commands:
170
+
171
+ ```bash
172
+ pyhashkit commands
173
+ ```
174
+
175
+ ---
176
+
177
+ # Python API
178
+
179
+ ## Hash Text
95
180
 
96
181
  ```python
97
182
  from pyhashkit import hash_text
@@ -101,7 +186,7 @@ result = hash_text("Hello World")
101
186
  print(result)
102
187
  ```
103
188
 
104
- ### Hash Text Using MD5
189
+ ## Hash Text Using MD5
105
190
 
106
191
  ```python
107
192
  from pyhashkit import hash_text
@@ -114,7 +199,7 @@ result = hash_text(
114
199
  print(result)
115
200
  ```
116
201
 
117
- ### Hash File
202
+ ## Hash File
118
203
 
119
204
  ```python
120
205
  from pyhashkit import hash_file
@@ -124,7 +209,7 @@ result = hash_file("example.txt")
124
209
  print(result)
125
210
  ```
126
211
 
127
- ### Hash File Using SHA-512
212
+ ## Hash File Using SHA-512
128
213
 
129
214
  ```python
130
215
  from pyhashkit import hash_file
@@ -139,11 +224,43 @@ print(result)
139
224
 
140
225
  ---
141
226
 
227
+ ## Version Information
228
+
229
+ ```python
230
+ from pyhashkit import __version__
231
+
232
+ print(__version__)
233
+ ```
234
+
235
+ ---
236
+
237
+ ## Available Exports
238
+
239
+ ```python
240
+ from pyhashkit import (
241
+ hash_text,
242
+ hash_file,
243
+ algorithms,
244
+ __version__
245
+ )
246
+ ```
247
+
248
+ ### algorithms
249
+
250
+ Returns a list of supported hashing algorithms available on the current Python installation.
251
+
252
+ ```python
253
+ from pyhashkit import algorithms
254
+
255
+ print(algorithms())
256
+ ```
257
+
258
+ ---
259
+
142
260
  ## Example Output
143
261
 
144
262
  ```text
145
- a591a6d40bf420404a011733cfb7b190
146
- d62c65bf0bcda32b57b277d9ad9f146e
263
+ a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e
147
264
  ```
148
265
 
149
266
  ---
@@ -155,6 +272,7 @@ PyHashKit/
155
272
  ├── pyhashkit/
156
273
  │ ├── __init__.py
157
274
  │ ├── hashing.py
275
+ │ ├── cli.py
158
276
  │ └── version.py
159
277
  ├── tests/
160
278
  │ └── test_hashing.py
@@ -170,12 +288,21 @@ PyHashKit/
170
288
  Contributions, bug reports, and feature requests are welcome.
171
289
 
172
290
  1. Fork the repository
173
- 2. Create a branch
291
+ 2. Create a new branch
174
292
  3. Make your changes
175
293
  4. Submit a pull request
176
294
 
177
295
  ---
178
296
 
297
+ ## Author
298
+
299
+ Developed by **JackMa**
300
+
301
+ GitHub:
302
+ https://github.com/Fmasterpro27
303
+
304
+ ---
305
+
179
306
  ## Links
180
307
 
181
308
  Homepage:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyHashKit
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A lightweight Python library for hashing text and files using multiple cryptographic algorithms.
5
5
  Home-page: https://github.com/Fmasterpro27/PyHashKit
6
6
  Author: fmasterpro27
@@ -30,7 +30,7 @@ Dynamic: requires-python
30
30
 
31
31
  # PyHashKit
32
32
 
33
- > A lightweight Python library for hashing text and files using multiple cryptographic algorithms.
33
+ > A lightweight Python library and CLI for hashing text and files using multiple cryptographic algorithms.
34
34
 
35
35
  [![PyPI version](https://img.shields.io/pypi/v/pyhashkit.svg)](https://pypi.org/project/pyhashkit/)
36
36
  [![Python versions](https://img.shields.io/pypi/pyversions/pyhashkit.svg)](https://pypi.org/project/pyhashkit/)
@@ -42,6 +42,7 @@ Dynamic: requires-python
42
42
 
43
43
  - 🔐 Hash text strings
44
44
  - 📄 Hash files of any size
45
+ - 💻 Built-in CLI support
45
46
  - ⚡ Supports multiple algorithms
46
47
  - 📦 Zero dependencies
47
48
  - 🐍 Python 3.8+
@@ -49,9 +50,17 @@ Dynamic: requires-python
49
50
 
50
51
  ---
51
52
 
53
+ ## Why PyHashKit?
54
+
55
+ PyHashKit provides a simple and beginner-friendly interface for Python's built-in hashing functionality.
56
+
57
+ Instead of manually working with `hashlib`, you can hash text and files with a single function call or directly from the command line.
58
+
59
+ ---
60
+
52
61
  ## Supported Algorithms
53
62
 
54
- PyHashKit supports any algorithm available through Python's built-in `hashlib`.
63
+ PyHashKit supports most algorithms available through Python's built-in `hashlib`.
55
64
 
56
65
  Common examples:
57
66
 
@@ -68,6 +77,15 @@ Common examples:
68
77
  - BLAKE2b
69
78
  - BLAKE2s
70
79
 
80
+ ### Not Supported
81
+
82
+ The following algorithms are currently not supported:
83
+
84
+ - SHAKE-128 (`shake_128`)
85
+ - SHAKE-256 (`shake_256`)
86
+
87
+ These algorithms require a custom digest length and are intentionally excluded to keep the API simple and consistent.
88
+
71
89
  ---
72
90
 
73
91
  ## Installation
@@ -89,9 +107,76 @@ print(hash_file("example.txt"))
89
107
 
90
108
  ---
91
109
 
92
- ## Python API
110
+ # Command Line Interface (CLI)
111
+
112
+ PyHashKit includes a built-in command-line interface for hashing text and files directly from your terminal.
113
+
114
+ ## Available Commands
115
+
116
+ ```text
117
+ text Hash a text string
118
+ file Hash a file
119
+ commands Show all commands
120
+ ```
121
+
122
+ ## Flags
123
+
124
+ ```text
125
+ -v, -V, --version
126
+ Show version information
127
+ ```
128
+
129
+ ## Options
93
130
 
94
- ### Hash Text
131
+ ```text
132
+ -a, --algorithm
133
+ Specify hashing algorithm
134
+ (default: sha256)
135
+ ```
136
+
137
+ ## Examples
138
+
139
+ Hash text:
140
+
141
+ ```bash
142
+ pyhashkit text "Hello World"
143
+ ```
144
+
145
+ Hash text using MD5:
146
+
147
+ ```bash
148
+ pyhashkit text "Hello World" -a md5
149
+ ```
150
+
151
+ Hash a file:
152
+
153
+ ```bash
154
+ pyhashkit file example.txt
155
+ ```
156
+
157
+ Hash a file using SHA-512:
158
+
159
+ ```bash
160
+ pyhashkit file example.txt -a sha512
161
+ ```
162
+
163
+ Show version information:
164
+
165
+ ```bash
166
+ pyhashkit -v
167
+ ```
168
+
169
+ Show all available commands:
170
+
171
+ ```bash
172
+ pyhashkit commands
173
+ ```
174
+
175
+ ---
176
+
177
+ # Python API
178
+
179
+ ## Hash Text
95
180
 
96
181
  ```python
97
182
  from pyhashkit import hash_text
@@ -101,7 +186,7 @@ result = hash_text("Hello World")
101
186
  print(result)
102
187
  ```
103
188
 
104
- ### Hash Text Using MD5
189
+ ## Hash Text Using MD5
105
190
 
106
191
  ```python
107
192
  from pyhashkit import hash_text
@@ -114,7 +199,7 @@ result = hash_text(
114
199
  print(result)
115
200
  ```
116
201
 
117
- ### Hash File
202
+ ## Hash File
118
203
 
119
204
  ```python
120
205
  from pyhashkit import hash_file
@@ -124,7 +209,7 @@ result = hash_file("example.txt")
124
209
  print(result)
125
210
  ```
126
211
 
127
- ### Hash File Using SHA-512
212
+ ## Hash File Using SHA-512
128
213
 
129
214
  ```python
130
215
  from pyhashkit import hash_file
@@ -139,11 +224,43 @@ print(result)
139
224
 
140
225
  ---
141
226
 
227
+ ## Version Information
228
+
229
+ ```python
230
+ from pyhashkit import __version__
231
+
232
+ print(__version__)
233
+ ```
234
+
235
+ ---
236
+
237
+ ## Available Exports
238
+
239
+ ```python
240
+ from pyhashkit import (
241
+ hash_text,
242
+ hash_file,
243
+ algorithms,
244
+ __version__
245
+ )
246
+ ```
247
+
248
+ ### algorithms
249
+
250
+ Returns a list of supported hashing algorithms available on the current Python installation.
251
+
252
+ ```python
253
+ from pyhashkit import algorithms
254
+
255
+ print(algorithms())
256
+ ```
257
+
258
+ ---
259
+
142
260
  ## Example Output
143
261
 
144
262
  ```text
145
- a591a6d40bf420404a011733cfb7b190
146
- d62c65bf0bcda32b57b277d9ad9f146e
263
+ a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e
147
264
  ```
148
265
 
149
266
  ---
@@ -155,6 +272,7 @@ PyHashKit/
155
272
  ├── pyhashkit/
156
273
  │ ├── __init__.py
157
274
  │ ├── hashing.py
275
+ │ ├── cli.py
158
276
  │ └── version.py
159
277
  ├── tests/
160
278
  │ └── test_hashing.py
@@ -170,12 +288,21 @@ PyHashKit/
170
288
  Contributions, bug reports, and feature requests are welcome.
171
289
 
172
290
  1. Fork the repository
173
- 2. Create a branch
291
+ 2. Create a new branch
174
292
  3. Make your changes
175
293
  4. Submit a pull request
176
294
 
177
295
  ---
178
296
 
297
+ ## Author
298
+
299
+ Developed by **JackMa**
300
+
301
+ GitHub:
302
+ https://github.com/Fmasterpro27
303
+
304
+ ---
305
+
179
306
  ## Links
180
307
 
181
308
  Homepage:
@@ -5,8 +5,10 @@ setup.py
5
5
  PyHashKit.egg-info/PKG-INFO
6
6
  PyHashKit.egg-info/SOURCES.txt
7
7
  PyHashKit.egg-info/dependency_links.txt
8
+ PyHashKit.egg-info/entry_points.txt
8
9
  PyHashKit.egg-info/top_level.txt
9
10
  pyhashkit/__init__.py
11
+ pyhashkit/cli.py
10
12
  pyhashkit/hashing.py
11
13
  pyhashkit/version.py
12
14
  test/test_hashing.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pyhashkit = pyhashkit.cli:main
@@ -0,0 +1,291 @@
1
+ # PyHashKit
2
+
3
+ > A lightweight Python library and CLI for hashing text and files using multiple cryptographic algorithms.
4
+
5
+ [![PyPI version](https://img.shields.io/pypi/v/pyhashkit.svg)](https://pypi.org/project/pyhashkit/)
6
+ [![Python versions](https://img.shields.io/pypi/pyversions/pyhashkit.svg)](https://pypi.org/project/pyhashkit/)
7
+ [![License](https://img.shields.io/pypi/l/pyhashkit.svg)](LICENSE)
8
+
9
+ ---
10
+
11
+ ## Features
12
+
13
+ - 🔐 Hash text strings
14
+ - 📄 Hash files of any size
15
+ - 💻 Built-in CLI support
16
+ - ⚡ Supports multiple algorithms
17
+ - 📦 Zero dependencies
18
+ - 🐍 Python 3.8+
19
+ - 🚀 Lightweight and fast
20
+
21
+ ---
22
+
23
+ ## Why PyHashKit?
24
+
25
+ PyHashKit provides a simple and beginner-friendly interface for Python's built-in hashing functionality.
26
+
27
+ Instead of manually working with `hashlib`, you can hash text and files with a single function call or directly from the command line.
28
+
29
+ ---
30
+
31
+ ## Supported Algorithms
32
+
33
+ PyHashKit supports most algorithms available through Python's built-in `hashlib`.
34
+
35
+ Common examples:
36
+
37
+ - SHA-256
38
+ - SHA-512
39
+ - SHA-224
40
+ - SHA-384
41
+ - MD5
42
+ - SHA-1
43
+ - SHA3-224
44
+ - SHA3-256
45
+ - SHA3-384
46
+ - SHA3-512
47
+ - BLAKE2b
48
+ - BLAKE2s
49
+
50
+ ### Not Supported
51
+
52
+ The following algorithms are currently not supported:
53
+
54
+ - SHAKE-128 (`shake_128`)
55
+ - SHAKE-256 (`shake_256`)
56
+
57
+ These algorithms require a custom digest length and are intentionally excluded to keep the API simple and consistent.
58
+
59
+ ---
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ pip install PyHashKit
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Quick Start
70
+
71
+ ```python
72
+ from pyhashkit import hash_text, hash_file
73
+
74
+ print(hash_text("Hello World"))
75
+ print(hash_file("example.txt"))
76
+ ```
77
+
78
+ ---
79
+
80
+ # Command Line Interface (CLI)
81
+
82
+ PyHashKit includes a built-in command-line interface for hashing text and files directly from your terminal.
83
+
84
+ ## Available Commands
85
+
86
+ ```text
87
+ text Hash a text string
88
+ file Hash a file
89
+ commands Show all commands
90
+ ```
91
+
92
+ ## Flags
93
+
94
+ ```text
95
+ -v, -V, --version
96
+ Show version information
97
+ ```
98
+
99
+ ## Options
100
+
101
+ ```text
102
+ -a, --algorithm
103
+ Specify hashing algorithm
104
+ (default: sha256)
105
+ ```
106
+
107
+ ## Examples
108
+
109
+ Hash text:
110
+
111
+ ```bash
112
+ pyhashkit text "Hello World"
113
+ ```
114
+
115
+ Hash text using MD5:
116
+
117
+ ```bash
118
+ pyhashkit text "Hello World" -a md5
119
+ ```
120
+
121
+ Hash a file:
122
+
123
+ ```bash
124
+ pyhashkit file example.txt
125
+ ```
126
+
127
+ Hash a file using SHA-512:
128
+
129
+ ```bash
130
+ pyhashkit file example.txt -a sha512
131
+ ```
132
+
133
+ Show version information:
134
+
135
+ ```bash
136
+ pyhashkit -v
137
+ ```
138
+
139
+ Show all available commands:
140
+
141
+ ```bash
142
+ pyhashkit commands
143
+ ```
144
+
145
+ ---
146
+
147
+ # Python API
148
+
149
+ ## Hash Text
150
+
151
+ ```python
152
+ from pyhashkit import hash_text
153
+
154
+ result = hash_text("Hello World")
155
+
156
+ print(result)
157
+ ```
158
+
159
+ ## Hash Text Using MD5
160
+
161
+ ```python
162
+ from pyhashkit import hash_text
163
+
164
+ result = hash_text(
165
+ "Hello World",
166
+ algorithm="md5"
167
+ )
168
+
169
+ print(result)
170
+ ```
171
+
172
+ ## Hash File
173
+
174
+ ```python
175
+ from pyhashkit import hash_file
176
+
177
+ result = hash_file("example.txt")
178
+
179
+ print(result)
180
+ ```
181
+
182
+ ## Hash File Using SHA-512
183
+
184
+ ```python
185
+ from pyhashkit import hash_file
186
+
187
+ result = hash_file(
188
+ "example.txt",
189
+ algorithm="sha512"
190
+ )
191
+
192
+ print(result)
193
+ ```
194
+
195
+ ---
196
+
197
+ ## Version Information
198
+
199
+ ```python
200
+ from pyhashkit import __version__
201
+
202
+ print(__version__)
203
+ ```
204
+
205
+ ---
206
+
207
+ ## Available Exports
208
+
209
+ ```python
210
+ from pyhashkit import (
211
+ hash_text,
212
+ hash_file,
213
+ algorithms,
214
+ __version__
215
+ )
216
+ ```
217
+
218
+ ### algorithms
219
+
220
+ Returns a list of supported hashing algorithms available on the current Python installation.
221
+
222
+ ```python
223
+ from pyhashkit import algorithms
224
+
225
+ print(algorithms())
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Example Output
231
+
232
+ ```text
233
+ a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e
234
+ ```
235
+
236
+ ---
237
+
238
+ ## Project Structure
239
+
240
+ ```text
241
+ PyHashKit/
242
+ ├── pyhashkit/
243
+ │ ├── __init__.py
244
+ │ ├── hashing.py
245
+ │ ├── cli.py
246
+ │ └── version.py
247
+ ├── tests/
248
+ │ └── test_hashing.py
249
+ ├── pyproject.toml
250
+ ├── LICENSE
251
+ └── README.md
252
+ ```
253
+
254
+ ---
255
+
256
+ ## Contributing
257
+
258
+ Contributions, bug reports, and feature requests are welcome.
259
+
260
+ 1. Fork the repository
261
+ 2. Create a new branch
262
+ 3. Make your changes
263
+ 4. Submit a pull request
264
+
265
+ ---
266
+
267
+ ## Author
268
+
269
+ Developed by **JackMa**
270
+
271
+ GitHub:
272
+ https://github.com/Fmasterpro27
273
+
274
+ ---
275
+
276
+ ## Links
277
+
278
+ Homepage:
279
+ https://github.com/Fmasterpro27/PyHashKit
280
+
281
+ Issues:
282
+ https://github.com/Fmasterpro27/PyHashKit/issues
283
+
284
+ PyPI:
285
+ https://pypi.org/project/pyhashkit/
286
+
287
+ ---
288
+
289
+ ## License
290
+
291
+ Licensed under the Apache License 2.0.
@@ -0,0 +1,11 @@
1
+ from .hashing import hash_text, hash_file, algorithms
2
+ from importlib.metadata import version
3
+
4
+ __version__ = version("PyHashKit")
5
+
6
+ __all__ = [
7
+ "hash_text",
8
+ "hash_file",
9
+ "algorithms",
10
+ "__version__"
11
+ ]
@@ -0,0 +1,142 @@
1
+ import argparse
2
+
3
+ from .hashing import hash_text, hash_file, algorithms
4
+ from importlib.metadata import version
5
+
6
+
7
+ __version__ = version("PyHashKit")
8
+
9
+
10
+ def main():
11
+ parser = argparse.ArgumentParser(
12
+ prog="pyhashkit",
13
+ description="PyHashKit - Hash text and files using various algorithms",
14
+ )
15
+
16
+ parser.add_argument(
17
+ "-v",
18
+ "-V",
19
+ "--version",
20
+ action="store_true",
21
+ help="Show PyHashKit version",
22
+ )
23
+
24
+ subparsers = parser.add_subparsers(
25
+ dest="command",
26
+ help="Available commands",
27
+ )
28
+
29
+ text_parser = subparsers.add_parser(
30
+ "text",
31
+ help="Hash a text string",
32
+ )
33
+
34
+ text_parser.add_argument(
35
+ "text",
36
+ help="Text to hash",
37
+ )
38
+
39
+
40
+ text_parser.add_argument(
41
+ "-a",
42
+ "--algorithm",
43
+ default="sha256",
44
+ help="Hash algorithm (default: sha256)",
45
+ )
46
+
47
+ file_parser = subparsers.add_parser(
48
+ "file",
49
+ help="Hash a file",
50
+ )
51
+
52
+ file_parser.add_argument(
53
+ "path",
54
+ help="Path to file",
55
+ )
56
+
57
+ file_parser.add_argument(
58
+ "-a",
59
+ "--algorithm",
60
+ default="sha256",
61
+ help="Hash algorithm (default: sha256)",
62
+ )
63
+
64
+ subparsers.add_parser(
65
+ "commands",
66
+ help="List all available commands",
67
+ )
68
+
69
+ subparsers.add_parser(
70
+ "algorithms",
71
+ help="List all available hashing algorithms",
72
+ )
73
+
74
+ args = parser.parse_args()
75
+
76
+ if args.version:
77
+ print(f"PyHashKit v{__version__}")
78
+ return
79
+
80
+ try:
81
+ if args.command == "text":
82
+ print(hash_text(args.text, args.algorithm))
83
+
84
+ elif args.command in ("algorithms"):
85
+ print("Available Algorithms:")
86
+
87
+ for alg in algorithms():
88
+ print(f" - {alg}")
89
+
90
+ elif args.command == "file":
91
+ print(hash_file(args.path, args.algorithm))
92
+
93
+ elif args.command == "commands":
94
+ print("""
95
+ Available Commands:
96
+
97
+ text Hash a text string
98
+ file Hash a file
99
+ commands Show all commands
100
+
101
+ Flags:
102
+
103
+ -v, -V,
104
+ --version Show version information
105
+
106
+ Options:
107
+
108
+ -a, --algorithm
109
+ Specify hashing algorithm
110
+ (default: sha256)
111
+
112
+ Examples:
113
+
114
+ pyhashkit text "Hello World"
115
+
116
+ pyhashkit text "Hello World" -a md5
117
+
118
+ pyhashkit file example.txt
119
+
120
+ pyhashkit file example.txt -a sha512
121
+
122
+ pyhashkit -v
123
+ """)
124
+
125
+ else:
126
+ parser.print_help()
127
+
128
+ except FileNotFoundError:
129
+ print(f"Error: File not found: {args.path}")
130
+
131
+ except PermissionError:
132
+ print(f"Error: Permission denied: {args.path}")
133
+
134
+ except ValueError as e:
135
+ print(f"Error: {e}")
136
+
137
+ except Exception as e:
138
+ print(f"Unexpected error: {e}")
139
+
140
+
141
+ if __name__ == "__main__":
142
+ main()
@@ -0,0 +1,60 @@
1
+ import hashlib
2
+
3
+ def algorithms():
4
+ return sorted(hashlib.algorithms_available)
5
+
6
+
7
+ def hash_text(text: str, algorithm: str = "sha256") -> str:
8
+ if not isinstance(text, str):
9
+ raise TypeError(
10
+ "text must be a string"
11
+ )
12
+
13
+ try:
14
+ hash_obj = hashlib.new(algorithm)
15
+ except ValueError:
16
+ raise ValueError(
17
+ f"Unsupported algorithm: {algorithm}"
18
+ )
19
+
20
+ hash_obj.update(text.encode("utf-8"))
21
+ return hash_obj.hexdigest()
22
+
23
+
24
+ def hash_file(file_path: str, algorithm: str = "sha256") -> str:
25
+ if not isinstance(file_path, str):
26
+ raise TypeError(
27
+ "file_path must be a string"
28
+ )
29
+
30
+ try:
31
+ hash_obj = hashlib.new(algorithm)
32
+ except ValueError:
33
+ raise ValueError(
34
+ f"Unsupported algorithm: {algorithm}"
35
+ )
36
+
37
+ try:
38
+ with open(file_path, "rb") as f:
39
+ for chunk in iter(
40
+ lambda: f.read(8192),
41
+ b""
42
+ ):
43
+ hash_obj.update(chunk)
44
+
45
+ except FileNotFoundError:
46
+ raise FileNotFoundError(
47
+ f"File not found: {file_path}"
48
+ )
49
+
50
+ except PermissionError:
51
+ raise PermissionError(
52
+ f"Permission denied: {file_path}"
53
+ )
54
+
55
+ except OSError as e:
56
+ raise OSError(
57
+ f"Failed to read file: {e}"
58
+ )
59
+
60
+ return hash_obj.hexdigest()
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "PyHashKit"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  description = "A lightweight Python library for hashing text and files using multiple cryptographic algorithms."
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -37,6 +37,8 @@ classifiers = [
37
37
  "Programming Language :: Python :: 3.13",
38
38
  ]
39
39
 
40
+ [project.scripts]
41
+ pyhashkit = "pyhashkit.cli:main"
40
42
 
41
43
  [project.urls]
42
44
  Homepage = "https://github.com/Fmasterpro27/PyHashKit"
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="PyHashKit",
8
- version="0.1.0",
8
+ version="0.2.0",
9
9
  author="fmasterpro27",
10
10
  description="A modern Python toolkit for file hashing, checksum generation, verification, and integrity checking.",
11
11
  long_description=long_description,
@@ -23,8 +23,9 @@ setup(
23
23
  "License :: OSI Approved :: Apache Software License",
24
24
  "Operating System :: OS Independent",
25
25
  ],
26
+ pyhashkit = "pyhashkit.cli:main",
26
27
  python_requires=">=3.8",
27
- install_requires=[], # hashing.py only uses standard library 'hashlib'
28
+ install_requires=[],
28
29
  extras_require={
29
30
  "test": ["pytest"],
30
31
  },
@@ -1,7 +1,7 @@
1
1
  import unittest
2
2
  import os
3
3
  import tempfile
4
- from pyhashkit.hashing import hash_text, hash_file
4
+ from pyhashkit.hashing import hash_text, hash_file, algorithms
5
5
 
6
6
  class TestHashing(unittest.TestCase):
7
7
  def test_hash_text_default_sha256(self):
@@ -36,5 +36,33 @@ class TestHashing(unittest.TestCase):
36
36
  with self.assertRaises(FileNotFoundError):
37
37
  hash_file("non_existent_file.txt")
38
38
 
39
+ def test_algorithms(self):
40
+ algos = algorithms()
41
+
42
+ self.assertIsInstance(algos, list)
43
+ self.assertGreater(len(algos), 0)
44
+
45
+ self.assertIn("sha256", algos)
46
+
47
+ def test_hash_text_all_algorithms(self):
48
+ skip = {
49
+ "shake_128",
50
+ "shake_256"
51
+ }
52
+
53
+ for algo in algorithms():
54
+ if algo in skip:
55
+ continue
56
+
57
+ result = hash_text(
58
+ "hello world",
59
+ algo
60
+ )
61
+
62
+ self.assertIsInstance(
63
+ result,
64
+ str
65
+ )
66
+
39
67
  if __name__ == "__main__":
40
68
  unittest.main()
pyhashkit-0.1.0/README.md DELETED
@@ -1,164 +0,0 @@
1
- # PyHashKit
2
-
3
- > A lightweight Python library for hashing text and files using multiple cryptographic algorithms.
4
-
5
- [![PyPI version](https://img.shields.io/pypi/v/pyhashkit.svg)](https://pypi.org/project/pyhashkit/)
6
- [![Python versions](https://img.shields.io/pypi/pyversions/pyhashkit.svg)](https://pypi.org/project/pyhashkit/)
7
- [![License](https://img.shields.io/pypi/l/pyhashkit.svg)](LICENSE)
8
-
9
- ---
10
-
11
- ## Features
12
-
13
- - 🔐 Hash text strings
14
- - 📄 Hash files of any size
15
- - ⚡ Supports multiple algorithms
16
- - 📦 Zero dependencies
17
- - 🐍 Python 3.8+
18
- - 🚀 Lightweight and fast
19
-
20
- ---
21
-
22
- ## Supported Algorithms
23
-
24
- PyHashKit supports any algorithm available through Python's built-in `hashlib`.
25
-
26
- Common examples:
27
-
28
- - SHA-256
29
- - SHA-512
30
- - SHA-224
31
- - SHA-384
32
- - MD5
33
- - SHA-1
34
- - SHA3-224
35
- - SHA3-256
36
- - SHA3-384
37
- - SHA3-512
38
- - BLAKE2b
39
- - BLAKE2s
40
-
41
- ---
42
-
43
- ## Installation
44
-
45
- ```bash
46
- pip install PyHashKit
47
- ```
48
-
49
- ---
50
-
51
- ## Quick Start
52
-
53
- ```python
54
- from pyhashkit import hash_text, hash_file
55
-
56
- print(hash_text("Hello World"))
57
- print(hash_file("example.txt"))
58
- ```
59
-
60
- ---
61
-
62
- ## Python API
63
-
64
- ### Hash Text
65
-
66
- ```python
67
- from pyhashkit import hash_text
68
-
69
- result = hash_text("Hello World")
70
-
71
- print(result)
72
- ```
73
-
74
- ### Hash Text Using MD5
75
-
76
- ```python
77
- from pyhashkit import hash_text
78
-
79
- result = hash_text(
80
- "Hello World",
81
- algorithm="md5"
82
- )
83
-
84
- print(result)
85
- ```
86
-
87
- ### Hash File
88
-
89
- ```python
90
- from pyhashkit import hash_file
91
-
92
- result = hash_file("example.txt")
93
-
94
- print(result)
95
- ```
96
-
97
- ### Hash File Using SHA-512
98
-
99
- ```python
100
- from pyhashkit import hash_file
101
-
102
- result = hash_file(
103
- "example.txt",
104
- algorithm="sha512"
105
- )
106
-
107
- print(result)
108
- ```
109
-
110
- ---
111
-
112
- ## Example Output
113
-
114
- ```text
115
- a591a6d40bf420404a011733cfb7b190
116
- d62c65bf0bcda32b57b277d9ad9f146e
117
- ```
118
-
119
- ---
120
-
121
- ## Project Structure
122
-
123
- ```text
124
- PyHashKit/
125
- ├── pyhashkit/
126
- │ ├── __init__.py
127
- │ ├── hashing.py
128
- │ └── version.py
129
- ├── tests/
130
- │ └── test_hashing.py
131
- ├── pyproject.toml
132
- ├── LICENSE
133
- └── README.md
134
- ```
135
-
136
- ---
137
-
138
- ## Contributing
139
-
140
- Contributions, bug reports, and feature requests are welcome.
141
-
142
- 1. Fork the repository
143
- 2. Create a branch
144
- 3. Make your changes
145
- 4. Submit a pull request
146
-
147
- ---
148
-
149
- ## Links
150
-
151
- Homepage:
152
- https://github.com/Fmasterpro27/PyHashKit
153
-
154
- Issues:
155
- https://github.com/Fmasterpro27/PyHashKit/issues
156
-
157
- PyPI:
158
- https://pypi.org/project/pyhashkit/
159
-
160
- ---
161
-
162
- ## License
163
-
164
- Licensed under the Apache License 2.0.
@@ -1,8 +0,0 @@
1
- from .hashing import hash_text, hash_file
2
- from .version import __version__
3
-
4
- __all__ = [
5
- "hash_text",
6
- "hash_file",
7
- "__version__"
8
- ]
@@ -1,28 +0,0 @@
1
- import hashlib
2
-
3
- def hash_text(text: str, algorithm: str = "sha256") -> str:
4
- try:
5
- hash_obj = hashlib.new(algorithm)
6
- except ValueError:
7
- raise ValueError(
8
- f"Unsupported algorithm: {algorithm}"
9
- )
10
-
11
- hash_obj.update(text.encode("utf-8"))
12
- return hash_obj.hexdigest()
13
-
14
-
15
-
16
- def hash_file(file_path: str, algorithm: str = "sha256") -> str:
17
- try:
18
- hash_obj = hashlib.new(algorithm)
19
- except ValueError:
20
- raise ValueError(
21
- f"Unsupported algorithm: {algorithm}"
22
- )
23
-
24
- with open(file_path, "rb") as f:
25
- for chunk in iter(lambda: f.read(8192), b""):
26
- hash_obj.update(chunk)
27
-
28
- return hash_obj.hexdigest()
File without changes
File without changes