[tor-commits] [onionperf/master] Adds file SHA-256 digests to index.xml

karsten at torproject.org karsten at torproject.org
Mon Jun 8 09:54:19 UTC 2020


commit 686c4f1acf02f5df96aff83af0add861a3e763d9
Author: Ana Custura <ana at netstat.org.uk>
Date:   Fri Jun 5 15:54:23 2020 +0100

    Adds file SHA-256 digests to index.xml
---
 onionperf/measurement.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/onionperf/measurement.py b/onionperf/measurement.py
index 676ccfc..d4435f0 100644
--- a/onionperf/measurement.py
+++ b/onionperf/measurement.py
@@ -3,7 +3,7 @@
   Authored by Rob Jansen, 2015
   See LICENSE for licensing information
 '''
-
+import hashlib
 import os, traceback, subprocess, threading, queue, logging, time, datetime, re, shlex
 from lxml import etree
 
@@ -27,6 +27,9 @@ def generate_docroot_index(docroot_path):
                 e.set("size", str(stat_result.st_size))
                 mtime = datetime.datetime.fromtimestamp(stat_result.st_mtime)
                 e.set("last_modified", mtime.replace(microsecond=0).isoformat(sep=' '))
+                with open(entry, 'rb') as f:
+                    fbytes = f.read()
+                    e.set("sha256sum", hashlib.sha256(fbytes).hexdigest())
     with open("{0}/index.xml".format(docroot_path), 'wb') as f:
         et = etree.ElementTree(root)
         et.write(f, pretty_print=True, xml_declaration=True)





More information about the tor-commits mailing list