summaryrefslogtreecommitdiff
path: root/tests/test-csp-hash.py
diff options
context:
space:
mode:
authorPreston Pan <ret2pop@nullring.xyz>2026-03-11 14:53:18 -0700
committerPreston Pan <ret2pop@nullring.xyz>2026-03-11 14:53:18 -0700
commit2ea09c36e53c30127122b10341394efb4e8f70fd (patch)
tree9c7b15117c9237e3eda72fa9487b58cd0aca918a /tests/test-csp-hash.py
parent9ed3176a5f627f488ee3804cfcca248620ad299b (diff)
parente52cf6c709dff76974580c01761f3a556c7a4883 (diff)
Merge branch 'feat/csp'
Diffstat (limited to 'tests/test-csp-hash.py')
-rw-r--r--tests/test-csp-hash.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/test-csp-hash.py b/tests/test-csp-hash.py
new file mode 100644
index 0000000..8401979
--- /dev/null
+++ b/tests/test-csp-hash.py
@@ -0,0 +1,10 @@
+import sys, re, hashlib, base64
+html = open(sys.argv[1]).read()
+match = re.search(r'<style[^>]*>(.*?)</style>', html, re.DOTALL | re.IGNORECASE)
+if match:
+ content = match.group(1).encode('utf-8')
+ print(base64.b64encode(hashlib.sha256(content).digest()).decode())
+ exit(0)
+else:
+ print('Error: Still could not find a <style> tag in the HTML.')
+ exit(1)