summary refs log tree commit diff
path: root/scripts/check_event_hash.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-05-06 11:41:19 +0100
committerErik Johnston <erik@matrix.org>2015-05-06 11:41:19 +0100
commit119e5d7702a1de0b196a374b53b646c06ee753e5 (patch)
treea617bb7f11b100e1b6fdbb92c462109950d64908 /scripts/check_event_hash.py
parentMerge pull request #138 from matrix-org/erikj/SYN-371 (diff)
downloadsynapse-119e5d7702a1de0b196a374b53b646c06ee753e5.tar.xz
Seperate scripts/ into scripts/ and scripts-dev/, where scripts/* are automatically added to the package
Diffstat (limited to 'scripts/check_event_hash.py')
-rw-r--r--scripts/check_event_hash.py50
1 files changed, 0 insertions, 50 deletions
diff --git a/scripts/check_event_hash.py b/scripts/check_event_hash.py
deleted file mode 100644
index 679afbd268..0000000000
--- a/scripts/check_event_hash.py
+++ /dev/null
@@ -1,50 +0,0 @@
-from synapse.crypto.event_signing import *
-from syutil.base64util import encode_base64
-
-import argparse
-import hashlib
-import sys
-import json
-
-
-class dictobj(dict):
-    def __init__(self, *args, **kargs):
-        dict.__init__(self, *args, **kargs)
-        self.__dict__ = self
-
-    def get_dict(self):
-        return dict(self)
-
-    def get_full_dict(self):
-        return dict(self)
-
-    def get_pdu_json(self):
-        return dict(self)
-
-
-def main():
-    parser = argparse.ArgumentParser()
-    parser.add_argument("input_json", nargs="?", type=argparse.FileType('r'),
-                        default=sys.stdin)
-    args = parser.parse_args()
-    logging.basicConfig()
-
-    event_json = dictobj(json.load(args.input_json))
-
-    algorithms = {
-        "sha256": hashlib.sha256,
-    }
-
-    for alg_name in event_json.hashes:
-        if check_event_content_hash(event_json, algorithms[alg_name]):
-            print "PASS content hash %s" % (alg_name,)
-        else:
-            print "FAIL content hash %s" % (alg_name,)
-
-    for algorithm in algorithms.values():
-        name, h_bytes = compute_event_reference_hash(event_json, algorithm)
-        print "Reference hash %s: %s" % (name, encode_base64(h_bytes))
-
-if __name__=="__main__":
-    main()
-