Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
129455f9
Unverified
Commit
129455f9
authored
Apr 04, 2022
by
Philip Meier
Committed by
GitHub
Apr 04, 2022
Browse files
indicate md5 checksum is not used for security (#5717)
* indicate md5 checksum is not used for security * add explanation
parent
316c3825
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
torchvision/datasets/utils.py
torchvision/datasets/utils.py
+5
-1
No files found.
torchvision/datasets/utils.py
View file @
129455f9
...
@@ -7,6 +7,7 @@ import os
...
@@ -7,6 +7,7 @@ import os
import
os.path
import
os.path
import
pathlib
import
pathlib
import
re
import
re
import
sys
import
tarfile
import
tarfile
import
urllib
import
urllib
import
urllib.error
import
urllib.error
...
@@ -62,7 +63,10 @@ def gen_bar_updater() -> Callable[[int, int, int], None]:
...
@@ -62,7 +63,10 @@ def gen_bar_updater() -> Callable[[int, int, int], None]:
def
calculate_md5
(
fpath
:
str
,
chunk_size
:
int
=
1024
*
1024
)
->
str
:
def
calculate_md5
(
fpath
:
str
,
chunk_size
:
int
=
1024
*
1024
)
->
str
:
md5
=
hashlib
.
md5
()
# Setting the `usedforsecurity` flag does not change anything about the functionality, but indicates that we are
# not using the MD5 checksum for cryptography. This enables its usage in restricted environments like FIPS. Without
# it torchvision.datasets is unusable in these environments since we perform a MD5 check everywhere.
md5
=
hashlib
.
md5
(
**
dict
(
usedforsecurity
=
False
)
if
sys
.
version_info
>=
(
3
,
9
)
else
dict
())
with
open
(
fpath
,
"rb"
)
as
f
:
with
open
(
fpath
,
"rb"
)
as
f
:
for
chunk
in
iter
(
lambda
:
f
.
read
(
chunk_size
),
b
""
):
for
chunk
in
iter
(
lambda
:
f
.
read
(
chunk_size
),
b
""
):
md5
.
update
(
chunk
)
md5
.
update
(
chunk
)
...
...
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