Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace hashlib.md5() with hashlib.blake2b() #2318

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions picard/coverart/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.


from hashlib import md5
from hashlib import blake2b
import os
import shutil
import tempfile
Expand Down Expand Up @@ -77,9 +77,7 @@ def __init__(self, data, prefix='picard', suffix=''):
self._filename = None
_datafile_mutex.lock()
try:
m = md5() # nosec
m.update(data)
self._hash = m.hexdigest()
self._hash = blake2b(data).hexdigest()
if self._hash not in _datafiles:
(fd, self._filename) = tempfile.mkstemp(prefix=prefix, suffix=suffix)
QObject.tagger.register_cleanup(self.delete_file)
Expand Down
10 changes: 7 additions & 3 deletions picard/tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

import argparse
from functools import partial
from hashlib import md5
from hashlib import blake2b
import logging
import os
import platform
Expand Down Expand Up @@ -1532,8 +1532,12 @@ def main(localedir=None, autoupdate=True):
if picard_args.stand_alone_instance:
identifier = uuid4().hex
else:
identifier = md5(picard_args.config_file.encode('utf8')).hexdigest() if picard_args.config_file else 'main' # nosec: B303
identifier += '_NP' if picard_args.no_plugins else ''
if picard_args.config_file:
identifier = blake2b(picard_args.config_file.encode('utf8'), digest_size=16).hexdigest()
else:
identifier = 'main'
if picard_args.no_plugins:
identifier += '_NP'

if picard_args.processable:
log.info("Sending messages to main instance: %r", picard_args.processable)
Expand Down
Loading