-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhashit.html
215 lines (199 loc) · 19.9 KB
/
hashit.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: package hashit</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>hashit</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/Users/javad/Dropbox/udvikling/projekter/hashit/hashit/hashit/__init__.py">/Users/javad/Dropbox/udvikling/projekter/hashit/hashit/hashit/__init__.py</a></font></td></tr></table>
<p><tt>hashit module for hashit command is contaning all the code for hashit<br>
<br>
hashit is an hashing application which main purpose is to replace all the 'default'<br>
hashing commands that comes with linux and also provide a usable hashing program<br>
for windows hence the choice of using python. while hashit supports both python 2 and 3<br>
i would strongly recommend using python3 because that python3 comes with a newer version<br>
of hashlib and therefore many new hash-functions, altough it is posible to add these into<br>
python2 with the <a href="#-load">load</a>() function which acts like a 'connecter' and enables hashit to use<br>
third-party hashing-functions as long as the have the same api as specified in docs/index.md<br>
<br>
The GLOBAL dict contains all the configurations for this program, translations, error messages<br>
settings, plugins and more.<br>
<br>
__algorithms__ is a list that contains all the builtin algorithms including crc32<br>
<br>
LICENSE:<br>
<br>
MIT License<br>
<br>
Copyright (c) 2020 Javad Shafique<br>
<br>
Permission is hereby granted, free of charge, to any person obtaining a copy<br>
of this software and associated documentation files (the "Software"), to deal<br>
in the Software without restriction, including without limitation the rights<br>
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br>
copies of the Software, and to permit persons to whom the Software is<br>
furnished to do so, subject to the following conditions:<br>
<br>
The above copyright notice and this permission notice shall be included in all<br>
copies or substantial portions of the Software.<br>
<br>
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br>
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br>
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br>
SOFTWARE.<br>
<br>
NO ONE CAN CLAIM OWNERSHIP OF THIS "SOFTWARE" AND ASSOCIATED DOCUMENTATION FILES.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="hashit.__main__.html">__main__</a><br>
</td><td width="25%" valign=top><a href="hashit.detection.html">detection</a><br>
</td><td width="25%" valign=top><a href="hashit.extra.html">extra</a><br>
</td><td width="25%" valign=top><a href="hashit.version.html">version</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="hashit.html#BSD">BSD</a>
</font></dt><dt><font face="helvetica, arial"><a href="hashit.html#SFV">SFV</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="BSD">class <strong>BSD</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#BSD">BSD</a>(filename=None, size=False)<br>
<br>
Parser for bsd and formater, also the<br>
same as <a href="#SFV">SFV</a>() but <a href="#BSD">BSD</a>() instead of sfv uses<br>
the bsd checksum output which is like this:<br>
hashname (filename) = hash [size]<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="BSD-__init__"><strong>__init__</strong></a>(self, filename=None, size=False)</dt><dd><tt>Inits bsd class with filename and use_size</tt></dd></dl>
<dl><dt><a name="BSD-read"><strong>read</strong></a>(self, filename=None, size=False, reader=None)</dt><dd><tt>Creates generator or uses generator that reads and parses bsd strings</tt></dd></dl>
<hr>
Static methods defined here:<br>
<dl><dt><a name="BSD-format"><strong>format</strong></a>(file_hash, file_path, hashname)</dt><dd><tt>Formats string in a bsd style format</tt></dd></dl>
<dl><dt><a name="BSD-parser"><strong>parser</strong></a>(line, use_size=False)</dt><dd><tt>Parses bsd string</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="SFV">class <strong>SFV</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#SFV">SFV</a>(filename=None, size=False)<br>
<br>
Class for parsing and creating sfv strings<br>
<a href="#SFV">SFV</a>() contains all functions needed for parsing,<br>
creating and formating <a href="#SFV">SFV</a> strings<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="SFV-__init__"><strong>__init__</strong></a>(self, filename=None, size=False)</dt><dd><tt>Inits sfv class with file and use_size</tt></dd></dl>
<dl><dt><a name="SFV-read"><strong>read</strong></a>(self, filename=None, size=False, reader=None)</dt><dd><tt>Creates generator or uses generator that reads and parses sfv compatible files using reader</tt></dd></dl>
<hr>
Static methods defined here:<br>
<dl><dt><a name="SFV-format"><strong>format</strong></a>(file_hash, file_path, longest, size='')</dt><dd><tt>calculates the amount of spaces needed in a sfv file</tt></dd></dl>
<dl><dt><a name="SFV-parser"><strong>parser</strong></a>(line, use_size=False)</dt></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-Exit"><strong>Exit</strong></a> = exit(...)</dt><dd><tt>exit([status])<br>
<br>
Exit the interpreter by raising SystemExit(status).<br>
If the status is omitted or None, it defaults to zero (i.e., success).<br>
If the status is an integer, it will be used as the system exit status.<br>
If it is another kind of <a href="builtins.html#object">object</a>, it will be printed and the system<br>
exit status will be one (i.e., failure).</tt></dd></dl>
<dl><dt><a name="-blockIter"><strong>blockIter</strong></a>(afile, blocksize=65536)</dt><dd><tt>Will create a generator for reading a file</tt></dd></dl>
<dl><dt><a name="-check"><strong>check</strong></a>(path, hashit, usecolors=False, be_quiet=False, detecthash=True, sfv=False, size=False, bsdtag=False, strict=False, trace=False, dry_run=False)</dt><dd><tt>Uses check_() to print the error messages and statuses corrent (for CLI)<br>
they are seperated so that you can use the python api, if you so please.</tt></dd></dl>
<dl><dt><a name="-check_files"><strong>check_files</strong></a>(file_read, hashit, first_line, sfv=False, size=False, bsdtag=False, dry_run=False)</dt><dd><tt>Will read an file which have a <a href="#SFV">SFV</a> compatible checksum-file or a standard one and verify the files checksum<br>
by creating an generator which loops over another generator which parses/reads the file and then it will check<br>
if the hash and optionally the size of the files matches the current state of them. For more info on how this work<br>
see docs/index.md#technical.</tt></dd></dl>
<dl><dt><a name="-choose_hash"><strong>choose_hash</strong></a>(hash1, hashit, cli=True)</dt><dd><tt>Uses detect.decect to identify hashes with a high accuracy but when<br>
there if some issues it will take user input. CLI-only</tt></dd></dl>
<dl><dt><a name="-detect_format"><strong>detect_format</strong></a>(hashstr, use_size=False)</dt><dd><tt>Autodetect hash format, by checking the length and what it contains</tt></dd></dl>
<dl><dt><a name="-eprint"><strong>eprint</strong></a>(*args, **kwargs)</dt><dd><tt>Prints to stderr usefull for warnings and error messages</tt></dd></dl>
<dl><dt><a name="-fixpath"><strong>fixpath</strong></a>(path)</dt><dd><tt>Fixpath converts the releative path into an absolute path<br>
and if needed can append the path to the snap host-filesystem <br>
which if the application is in devmode gives hashit access to <br>
the hole filesystem, if you're not in devmode and you're still<br>
using snap, then you will need sudo to access the intire system.<br>
Also replaces / with \ on windows</tt></dd></dl>
<dl><dt><a name="-hashFile"><strong>hashFile</strong></a>(filename, hasher, memory_opt=False)</dt><dd><tt>hashFile is a simple way to hash files using diffrent methods</tt></dd></dl>
<dl><dt><a name="-hashIter"><strong>hashIter</strong></a>(bytesiter, hasher, ashexstr=True)</dt><dd><tt>Will hash the blockIter generator and return digest</tt></dd></dl>
<dl><dt><a name="-load"><strong>load</strong></a>(hashclass)</dt><dd><tt>Add hashes to GLOBAL.EXTRA which is the dict that contains all the "extra"<br>
hash-functions such as Crc32, which allows external hashing algorithms to <br>
be used as long as the have the same api as specified in docs/README.md<br>
<br>
returns True/False based on whether or not the data is loaded</tt></dd></dl>
<dl><dt><a name="-load_all"><strong>load_all</strong></a>(list_of_hashclasses)</dt><dd><tt>Just for it, a function that loads all plugins in a list</tt></dd></dl>
<dl><dt><a name="-new"><strong>new</strong></a>(hashname, data=b'')</dt><dd><tt>Custom hash-init function that returns the hashes<br>
depends on hashlib.new and GLOBAL["EXTRA"]. One of its'<br>
features is it's support for the python3 only shake-hash<br>
scheme were the default hash is shake_256 and the input is<br>
taken like this:<br>
shake_[amount of output]</tt></dd></dl>
<dl><dt><a name="-reader"><strong>reader</strong></a>(filename, mode='r', comments=True, newlines=False)</dt><dd><tt>Creates generator for a file or stdin, better for larger files not part of the MEMOPT,<br>
so an standard reader for most uses. Works like readlines but instead of a list it<br>
creates an generator that sortof clean the input before it is parsed by something like<br>
<a href="#BSD">BSD</a>() or <a href="#SFV">SFV</a>().</tt></dd></dl>
<dl><dt><a name="-supports_color"><strong>supports_color</strong></a>()</dt><dd><tt>Returns True if the running system's terminal supports color, and False<br>
otherwise.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>GLOBAL</strong> = {'ACCESS': True, 'BLANK': (None, True, False), 'COLORS': {'GREEN': '<font color="#c040c0">\x1b</font>[0;32m', 'RED': '<font color="#c040c0">\x1b</font>[0;31m', 'RESET': '<font color="#c040c0">\x1b</font>[0m', 'YELLOW': '<font color="#c040c0">\x1b</font>[0;33m'}, 'DEFAULTS': {'APPEND': False, 'COLORS': True, 'DETECT': False, 'DRYRUN': False, 'HASH': 'md5', 'MEMOPT': False, 'QUIET': False, 'RECURS': False, 'SIZE': False, 'STRICT': False, ...}, 'DEVMODE': True, 'ERRORS': {'FileNotFoundError': "Error, file seems to be missing calling systemd to confirm 'sure you haved checked the MBR?'", 'IndexError': 'Out of range, cause i am not that big :)', 'OSError': {'END': 'JDK, so something happend with your os, message: ', 'linux': 'So {} , to be continued...<font color="#c040c0">\n</font>', 'macos': 'Macos (Sierra+) and OSX (El Captain-) thank god for apples naming', 'windows': 'Windows 10, windows 8(.1), windows 7 (sp*), wind...p*), windows 98/95, windows NT *. OK not that bad'}, 'TypeError': 'Wrong type used (in cli-arguments) - please use a static programming language', 'ValueError': 'Wrong type or mood?! :)'}, 'EXTRA': {'crc32': <class 'hashit.extra.Crc32'>}, 'HASH_STR': 'Hello World!', 'IF_NO_ARGS': ['--string'], 'MESSAGES': {'CUR_FORM': 'current format is', 'DRYRUN_NOT': 'Does not support --dry-run', 'EMPTY_CHK': 'checksum file is empty', 'FAIL': 'FAILED', 'FILE_NOT': 'File does not exist', 'HASH_NOT': 'is not a valid hash', 'LENGTH_NOT': 'The files does not have the same length', 'LOAD_FAIL': 'Failed to load', 'MAYBE': 'Maybe', 'MAYBE_M': 'Did you maybe mean:', ...}, ...}<br>
<strong>__algorithms__</strong> = ['md5', 'sha1', 'crc32', 'sha256', 'sha384', 'sha512', 'sha224', 'blake2b', 'blake2s', 'sha3_224', 'sha3_384', 'sha3_512', 'sha3_256']<br>
<strong>__help__</strong> = 'Hashit is an hashing program which can be uses t...ot the idea to make such a program using<font color="#c040c0">\n</font>python.<font color="#c040c0">\n</font>'<br>
<strong>__license__</strong> = 'MIT, Copyright (c) 2017-2020 Javad Shafique'<br>
<strong>print_function</strong> = _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 65536)<br>
<strong>with_statement</strong> = _Feature((2, 5, 0, 'alpha', 1), (2, 6, 0, 'alpha', 0), 32768)</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
<tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
<td width="100%">Javad Shafique</td></tr></table>
</body></html>