From 7dfdea2395a77695ec525e82437bec2422de513d Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 21 May 2026 17:16:31 +0200 Subject: [PATCH] Raise descriptive error if hashlib.file_digest is not available. --- RNS/Cryptography/Hashes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RNS/Cryptography/Hashes.py b/RNS/Cryptography/Hashes.py index a96c8e1d..87cda589 100644 --- a/RNS/Cryptography/Hashes.py +++ b/RNS/Cryptography/Hashes.py @@ -65,4 +65,6 @@ def sha512(data): def file_sha256(file): if not hashlib: raise SystemError("The hashlib module is not available on this system") + # TODO: Could implement fallback for old snakes here + if not hasattr(hashlib, "file_digest"): raise SystemError("The file_digest method is not available on this system. This functionality requires Python 3.11 or later.") else: return hashlib.file_digest(file, "sha256").digest()