FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
winpython/hash.py at master · DevLang-Python/winpython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
DevLang-Python
/
winpython
Public
forked from
winpython/winpython
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
winpython
/
hash.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (46 loc) · 1.18 KB
Breadcrumbs
winpython
/
hash.py
Copy path
File metadata and controls
58 lines (46 loc) · 1.18 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 23 21:30:06 2015
@author: famille
"""
import
io
import
os
import
sys
import
hashlib
def
give_hash
(
file_in
,
with_this
):
with
io
.
open
(
file_in
,
'rb'
)
as
f
:
return
with_this
(
f
.
read
()).
hexdigest
()
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
<
2
:
print
(
"Usage: "
+
sys
.
argv
[
0
]
+
" github-user [github-project]"
)
exit
(
1
)
file
=
sys
.
argv
[
1
]
header
=
(
" MD5"
+
" "
*
(
32
-
4
)
+
" | SHA-1"
+
" "
*
(
40
-
5
)
+
" | SHA-256"
+
" "
*
(
64
-
7
)
+
" | Binary"
+
" "
*
(
33
-
5
)
+
"| Size"
+
" "
*
(
20
-
6
)
+
" | SHA3-256"
+
" "
*
(
64
-
7
)
)
line
=
"|"
.
join
(
[
"-"
*
len
(
i
)
for
i
in
header
.
split
(
"|"
)]
)
print
(
header
)
print
(
line
)
print
(
""
+
f"
{
give_hash
(
file
,
hashlib
.
md5
)
}
| "
+
f"
{
give_hash
(
file
,
hashlib
.
sha1
)
}
| "
+
f"
{
give_hash
(
file
,
hashlib
.
sha256
)
}
| "
+
f"
{
os
.
path
.
basename
(
file
):33
}
|"
+
f"
{
os
.
path
.
getsize
(
file
):13,
}
"
.
replace
(
","
,
" "
)
+
' Bytes'
+
f" |
{
give_hash
(
file
,
hashlib
.
sha3_256
)
}
"
)
Back
|
FazBrowse Home
|
New Git URL