summaryrefslogtreecommitdiffstats
path: root/crxid
diff options
context:
space:
mode:
Diffstat (limited to 'crxid')
-rwxr-xr-xcrxid23
1 files changed, 23 insertions, 0 deletions
diff --git a/crxid b/crxid
new file mode 100755
index 0000000..7c0236c
--- /dev/null
+++ b/crxid
@@ -0,0 +1,23 @@
+#! /bin/sh
+# Get CRX id from RSA key
+# usage: crxid PEM_FILE
+
+set -efu
+
+pem_path=$1
+
+digest=$(
+ openssl rsa -in "$pem_path" -pubout -outform der 2>/dev/null |
+ openssl dgst -sha256 -hex |
+ sed 's/^(stdin)= //;s/.*/\U&/'
+)
+
+script="
+ obase=16;
+ ibase=16;
+ ascii_a=61;
+ $(echo $digest | cut -b-32 | sed 's/./ascii_a + &;/g')
+"
+
+echo "$script" | bc | xxd -r -p
+echo