aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2023-02-24 19:01:02 +0100
committerUlrich Müller <ulm@gentoo.org>2023-02-24 19:01:02 +0100
commite19ac3de05e997cbb78c7ea502738188b76ac6cb (patch)
treeec72f2850706736d17df34692eab385ef28ec7cf /g_sorcery
parentg_sorcery/ebuild.py: Update default EAPI from 5 to 8 (diff)
downloadg-sorcery-e19ac3de05e997cbb78c7ea502738188b76ac6cb.tar.gz
g-sorcery-e19ac3de05e997cbb78c7ea502738188b76ac6cb.tar.bz2
g-sorcery-e19ac3de05e997cbb78c7ea502738188b76ac6cb.zip
g_sorcery/fileutils.py: Add blake2b hash, drop sha256 and whirlpool
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Diffstat (limited to 'g_sorcery')
-rw-r--r--g_sorcery/fileutils.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 3440ec7..bb79aa9 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -182,7 +182,7 @@ class ManifestEntry(object):
"""
__slots__ = ('directory', 'name', 'ftype',
- 'size', 'sha256', 'sha512', 'whirlpool')
+ 'size', 'sha512', 'blake2b')
def __init__(self, directory, name, ftype):
self.directory = directory
@@ -194,18 +194,15 @@ class ManifestEntry(object):
"""
Digest a file associated with a manifest entry.
"""
- h_sha256 = hashlib.new('SHA256')
h_sha512 = hashlib.new('SHA512')
- h_whirlpool = hashlib.new('whirlpool')
+ h_blake2b = hashlib.new('blake2b')
with open(os.path.join(self.directory, self.name), 'rb') as f:
src = f.read()
- h_sha256.update(src)
h_sha512.update(src)
- h_whirlpool.update(src)
+ h_blake2b.update(src)
self.size = str(len(src))
- self.sha256 = h_sha256.hexdigest()
self.sha512 = h_sha512.hexdigest()
- self.whirlpool = h_whirlpool.hexdigest()
+ self.blake2b = h_blake2b.hexdigest()
def fast_manifest(directory):
@@ -230,8 +227,7 @@ def fast_manifest(directory):
manifest.append(ManifestEntry(directory, "metadata.xml", "MISC"))
manifest = [" ".join([m.ftype, m.name, m.size,
- "SHA256", m.sha256, "SHA512", m.sha512,
- "WHIRLPOOL", m.whirlpool])
+ "SHA512", m.sha512, "BLAKE2B", m.blake2b])
for m in manifest]
with open(os.path.join(directory, "Manifest"), 'w') as f: