Skip to content

Commit 522b15f

Browse files
Initial commit
0 parents  commit 522b15f

File tree

8 files changed

+633
-0
lines changed

8 files changed

+633
-0
lines changed

.gitignore

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
### Custom ###
2+
.idea/
3+
.vscode/
4+
**.swp
5+
6+
# Created by https://www.gitignore.io/api/pycharm,python
7+
# Edit at https://www.gitignore.io/?templates=pycharm,python
8+
9+
### PyCharm ###
10+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
11+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
12+
13+
# User-specific stuff
14+
.idea/**/workspace.xml
15+
.idea/**/tasks.xml
16+
.idea/**/usage.statistics.xml
17+
.idea/**/dictionaries
18+
.idea/**/shelf
19+
20+
# Generated files
21+
.idea/**/contentModel.xml
22+
23+
# Sensitive or high-churn files
24+
.idea/**/dataSources/
25+
.idea/**/dataSources.ids
26+
.idea/**/dataSources.local.xml
27+
.idea/**/sqlDataSources.xml
28+
.idea/**/dynamic.xml
29+
.idea/**/uiDesigner.xml
30+
.idea/**/dbnavigator.xml
31+
32+
# Gradle
33+
.idea/**/gradle.xml
34+
.idea/**/libraries
35+
36+
# Gradle and Maven with auto-import
37+
# When using Gradle or Maven with auto-import, you should exclude module files,
38+
# since they will be recreated, and may cause churn. Uncomment if using
39+
# auto-import.
40+
# .idea/modules.xml
41+
# .idea/*.iml
42+
# .idea/modules
43+
# *.iml
44+
# *.ipr
45+
46+
# CMake
47+
cmake-build-*/
48+
49+
# Mongo Explorer plugin
50+
.idea/**/mongoSettings.xml
51+
52+
# File-based project format
53+
*.iws
54+
55+
# IntelliJ
56+
out/
57+
58+
# mpeltonen/sbt-idea plugin
59+
.idea_modules/
60+
61+
# JIRA plugin
62+
atlassian-ide-plugin.xml
63+
64+
# Cursive Clojure plugin
65+
.idea/replstate.xml
66+
67+
# Crashlytics plugin (for Android Studio and IntelliJ)
68+
com_crashlytics_export_strings.xml
69+
crashlytics.properties
70+
crashlytics-build.properties
71+
fabric.properties
72+
73+
# Editor-based Rest Client
74+
.idea/httpRequests
75+
76+
# Android studio 3.1+ serialized cache file
77+
.idea/caches/build_file_checksums.ser
78+
79+
### PyCharm Patch ###
80+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
81+
82+
# *.iml
83+
# modules.xml
84+
# .idea/misc.xml
85+
# *.ipr
86+
87+
# Sonarlint plugin
88+
.idea/**/sonarlint/
89+
90+
# SonarQube Plugin
91+
.idea/**/sonarIssues.xml
92+
93+
# Markdown Navigator plugin
94+
.idea/**/markdown-navigator.xml
95+
.idea/**/markdown-navigator/
96+
97+
### Python ###
98+
# Byte-compiled / optimized / DLL files
99+
__pycache__/
100+
*.py[cod]
101+
*$py.class
102+
103+
# C extensions
104+
*.so
105+
106+
# Distribution / packaging
107+
.Python
108+
build/
109+
develop-eggs/
110+
dist/
111+
downloads/
112+
eggs/
113+
.eggs/
114+
lib/
115+
lib64/
116+
parts/
117+
sdist/
118+
var/
119+
wheels/
120+
pip-wheel-metadata/
121+
share/python-wheels/
122+
*.egg-info/
123+
.installed.cfg
124+
*.egg
125+
MANIFEST
126+
127+
# PyInstaller
128+
# Usually these files are written by a python script from a template
129+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
130+
*.manifest
131+
*.spec
132+
133+
# Installer logs
134+
pip-log.txt
135+
pip-delete-this-directory.txt
136+
137+
# Unit test / coverage reports
138+
htmlcov/
139+
.tox/
140+
.nox/
141+
.coverage
142+
.coverage.*
143+
.cache
144+
nosetests.xml
145+
coverage.xml
146+
*.cover
147+
.hypothesis/
148+
.pytest_cache/
149+
150+
# Translations
151+
*.mo
152+
*.pot
153+
154+
# Scrapy stuff:
155+
.scrapy
156+
157+
# Sphinx documentation
158+
docs/_build/
159+
160+
# PyBuilder
161+
target/
162+
163+
# pyenv
164+
.python-version
165+
166+
# pipenv
167+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
168+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
169+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
170+
# install all needed dependencies.
171+
#Pipfile.lock
172+
173+
# celery beat schedule file
174+
celerybeat-schedule
175+
176+
# SageMath parsed files
177+
*.sage.py
178+
179+
# Spyder project settings
180+
.spyderproject
181+
.spyproject
182+
183+
# Rope project settings
184+
.ropeproject
185+
186+
# Mr Developer
187+
.mr.developer.cfg
188+
.project
189+
.pydevproject
190+
191+
# mkdocs documentation
192+
/site
193+
194+
# mypy
195+
.mypy_cache/
196+
.dmypy.json
197+
dmypy.json
198+
199+
# Pyre type checker
200+
.pyre/
201+
202+
# End of https://www.gitignore.io/api/pycharm,python

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Cabbage Development
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# csum
2+
3+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
4+
[![PyPI](https://img.shields.io/pypi/v/csum?color=brightgreen)](https://pypi.org/project/csum)
5+
6+
## Introduction
7+
8+
`csum` is a CLI program which allows you to to verify checksums. The goal of `csum` is to minimise the effort required when you download a file and want to verify the checksum.
9+
10+
`csum` supports the most common checksum algorithms:
11+
12+
- `MD5`
13+
- `SHA256`
14+
- `SHA512`
15+
- `SHA1`
16+
17+
In addition, it supports `SHA3_512`, `SHA224`, `BLAKE2S`, `SHA3_224`, `SHA3_256`, `SHA3_384`, `SHA384` and `BLAKE2B`.
18+
19+
## Requirements
20+
21+
You need to have Python 3.6 or higher installed. This will allow you to install `csum` with Python's package manager, `pip`.
22+
23+
## How to install
24+
25+
To install `csum` with `pip`, run the command:
26+
27+
```bash
28+
pip install csum
29+
```
30+
31+
After this command completes, the `csum` executable should be available on the PATH.
32+
33+
# Quick start
34+
35+
`csum` is designed to be as simple to use as possible. For this reason, you don't need to specify the checksum type (e.g. `sha256`); `csum` will iterate through the most common types first.
36+
37+
## Usage examples
38+
39+
### File and checksum
40+
41+
You can call `csum` with a filename and checksum:
42+
43+
```bash
44+
csum file.zip 40f66f20b1ecb05cb11a9627520aafafbc8cd86b33eb8019cbea9925d8ca83ce2
45+
```
46+
47+
Or a checksum and filename:
48+
49+
```bash
50+
csum 40f66f20b1ecb05cb11a9627520aafafbc8cd86b33eb8019cbea9925d8ca83ce2 file.zip
51+
```
52+
53+
Absolute or relative paths, and paths including tilde (`~`), are accepted:
54+
55+
```bash
56+
csum ~/Downloads/file.zip 40f66f20b1ecb05cb11a9627520aafafbc8cd86b33eb8019cbea9925d8ca83ce2
57+
```
58+
59+
### Preformatted checksum/filename
60+
61+
Sometimes you are provided with a checksum of the form:
62+
63+
`40f66f20b1ecb05cb11a9627520aafafbc8cd86b33eb8019cbea9925d8ca83ce2 file.zip`
64+
65+
Assuming that the file is in the current working directory, you can simply copy this text and paste it after the `csum` command:
66+
67+
```bash
68+
csum 40f66f20b1ecb05cb11a9627520aafafbc8cd86b33eb8019cbea9925d8ca83ce2 file.zip
69+
```
70+
71+
If you prefer, you can supply it as a single argument:
72+
73+
```bash
74+
csum "40f66f20b1ecb05cb11a9627520aafafbc8cd86b33eb8019cbea9925d8ca83ce2 file.zip"
75+
```
76+
77+
> **Tip**: The number of spaces between the checksum and filename doesn't matter in either case.
78+
79+
### Manually choosing an algorithm
80+
81+
If you prefer to select a certain algorithm instead of iterating through them, you can use the `-a`/`--algorithm` parameter.
82+
83+
For example, using the SHA256 algorithm only:
84+
85+
```bash
86+
csum -a sha256 file.zip 40f66f20b1ecb05cb11a9627520aafafbc8cd86b33eb8019cbea9925d8ca83ce2
87+
```
88+
89+
> **Tip:** You can provide the algorithm name as either lower-case or upper-case, e.g. `sha256` or `SHA256`.
90+
91+
### Expected output
92+
93+
When you use `csum`, a positive response will be of the form:
94+
95+
```bash
96+
--------------------------------------------------------------------------------
97+
98+
File: file.zip
99+
Algorithm: SHA256
100+
101+
Expected checksum: 40f66f20b1ecb05cb11a9627520aafafbc8cd86b33eb8019cbea9925d8ca83ce2
102+
Calculated checksum: 40f66f20b1ecb05cb11a9627520aafafbc8cd86b33eb8019cbea9925d8ca83ce2
103+
104+
Checksums match ✔
105+
106+
--------------------------------------------------------------------------------
107+
108+
SUCCESS: SHA256 checksum matched file.
109+
```
110+
111+
A negative response will be of the form:
112+
113+
```bash
114+
--------------------------------------------------------------------------------
115+
116+
File: file.zip
117+
Expected checksum: 40f66f20b1ecb05cb11a9627520aafafbc8cd86b33eb8019cbea9925d8ca83ce2
118+
119+
Checksums do NOT match.
120+
121+
--------------------------------------------------------------------------------
122+
123+
FAILED: algorithm(s) did not match the checksum.
124+
```
125+
126+
# License
127+
128+
You may freely use, modify and redistribute this program under the terms of the MIT License. See [LICENSE](https://github.com/CabbageDevelopment/csum/blob/master/LICENSE).

csum/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2021 Cabbage Development
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
__version__ = "1.0.0"
23+
24+
25+
def init():
26+
from csum import checksums
27+
28+
29+
if __name__ == "__main__":
30+
init()

0 commit comments

Comments
 (0)