tests/f
branchstable
changeset 49556 9172bd49cedc
parent 48875 6000f5b25c9b
child 49874 e9d06ed64161
--- a/tests/f	Wed Oct 19 16:28:41 2022 +0200
+++ b/tests/f	Thu Nov 03 12:08:02 2022 +0100
@@ -63,7 +63,16 @@
         if isfile:
             if opts.type:
                 facts.append(b'file')
-            if any((opts.hexdump, opts.dump, opts.md5, opts.sha1, opts.sha256)):
+            needs_reading = (
+                opts.hexdump,
+                opts.dump,
+                opts.md5,
+                opts.sha1,
+                opts.raw_sha1,
+                opts.sha256,
+            )
+
+            if any(needs_reading):
                 with open(f, 'rb') as fobj:
                     content = fobj.read()
         elif islink:
@@ -101,6 +110,9 @@
         if opts.md5 and content is not None:
             h = hashlib.md5(content)
             facts.append(b'md5=%s' % binascii.hexlify(h.digest())[: opts.bytes])
+        if opts.raw_sha1 and content is not None:
+            h = hashlib.sha1(content)
+            facts.append(b'raw-sha1=%s' % h.digest()[: opts.bytes])
         if opts.sha1 and content is not None:
             h = hashlib.sha1(content)
             facts.append(
@@ -186,6 +198,12 @@
     )
     parser.add_option(
         "",
+        "--raw-sha1",
+        action="store_true",
+        help="show raw bytes of the sha1 hash of the content",
+    )
+    parser.add_option(
+        "",
         "--sha256",
         action="store_true",
         help="show sha256 hash of the content",