Skip to content

Commit

Permalink
add support for repos with sha512 checksums
Browse files Browse the repository at this point in the history
fixes #454
  • Loading branch information
furlongm committed Jan 12, 2023
1 parent e51cf35 commit a99c269
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import lzma
from colorama import Fore, Style
from enum import Enum
from hashlib import md5, sha1, sha256
from hashlib import md5, sha1, sha256, sha512
from progressbar import Bar, ETA, Percentage, ProgressBar
from patchman.signals import error_message

Expand All @@ -35,7 +35,7 @@

pbar = None
verbose = None
Checksum = Enum('Checksum', 'md5 sha sha1 sha256')
Checksum = Enum('Checksum', 'md5 sha sha1 sha256 sha512')


def get_verbosity():
Expand Down Expand Up @@ -203,6 +203,8 @@ def get_checksum(data, checksum_type):
checksum = get_sha1(data)
elif checksum_type == Checksum.sha256:
checksum = get_sha256(data)
elif checksum_type == Checksum.sha512:
checksum = get_sha512(data)
elif checksum_type == Checksum.md5:
checksum = get_md5(data)
else:
Expand All @@ -223,6 +225,12 @@ def get_sha256(data):
return sha256(data).hexdigest()


def get_sha512(data):
""" Return the sha512 checksum for data
"""
return sha512(data).hexdigest()


def get_md5(data):
""" Return the md5 checksum for data
"""
Expand Down

0 comments on commit a99c269

Please sign in to comment.