Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
5ec059b3
Commit
5ec059b3
authored
Sep 05, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
files: minor comments in digest
parent
e8d5e001
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
digest.py
gargantext/util/digest.py
+15
-0
No files found.
gargantext/util/digest.py
View file @
5ec059b3
"""
Creates MD5 hashes (used for unique filepaths)
NB this module could go inside util.files
"""
import
hashlib
import
hashlib
import
binascii
import
binascii
def
digest
(
value
,
algorithm
=
'md5'
):
def
digest
(
value
,
algorithm
=
'md5'
):
"""
Ex: b'm
\x00\x07\xe5
/z
\xfb
}Z
\x06
P
\xb0\xff\xb8\xa4\xd1
'
(16 bytes ranging from 0 to ff)
"""
m
=
hashlib
.
new
(
algorithm
)
m
=
hashlib
.
new
(
algorithm
)
m
.
update
(
value
)
m
.
update
(
value
)
return
m
.
digest
()
return
m
.
digest
()
def
str_digest
(
value
,
algorithm
=
'md5'
):
def
str_digest
(
value
,
algorithm
=
'md5'
):
"""
Ex: 6d0007e52f7afb7d5a0650b0ffb8a4d1
(32 hex chars)
"""
return
binascii
.
hexlify
(
digest
(
value
,
algorithm
))
.
decode
()
return
binascii
.
hexlify
(
digest
(
value
,
algorithm
))
.
decode
()
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