Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gajim
python-nbxmpp
Commits
27eabadd
Commit
27eabadd
authored
Dec 27, 2012
by
zimio
Browse files
prefer sha-1
parent
14db4017
Changes
1
Hide whitespace changes
Inline
Side-by-side
nbxmpp/protocol.py
View file @
27eabadd
...
...
@@ -1070,34 +1070,30 @@ class Hashes(Node):
hash_
=
None
# file_string can be a string or a file
if
type
(
file_string
)
==
str
:
# if it is a string
if
algo
==
'md5'
:
hl
=
hashlib
.
md5
()
elif
algo
==
'sha-1'
:
if
algo
==
'sha-1'
:
hl
=
hashlib
.
sha1
()
elif
algo
==
'md5'
:
hl
=
hashlib
.
md5
()
elif
algo
==
'sha-256'
:
hl
=
hashlib
.
sha256
()
elif
algo
==
'sha-512'
:
hl
=
hashlib
.
sha512
()
if
hl
:
hl
.
update
(
file_string
)
hash_
=
hl
.
hexdigest
()
else
:
# if it is a file
if
algo
==
'md5'
:
hl
=
hashlib
.
md5
()
elif
algo
==
'sha-1'
:
if
algo
==
'sha-1'
:
hl
=
hashlib
.
sha1
()
elif
algo
==
'md5'
:
hl
=
hashlib
.
md5
()
elif
algo
==
'sha-256'
:
hl
=
hashlib
.
sha256
()
elif
algo
==
'sha-512'
:
hl
=
hashlib
.
sha512
()
if
hl
:
for
line
in
file_string
:
hl
.
update
(
line
)
hash_
=
hl
.
hexdigest
()
return
hash_
def
addHash
(
self
,
hash_
,
algo
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment