summaryrefslogtreecommitdiffstats
path: root/crxid
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2021-01-03 15:27:06 +0100
committertv <tv@krebsco.de>2021-01-03 15:49:25 +0100
commit9feb2a8b377205ff8ab0f947ee511ec1fde5b9e7 (patch)
treec80cae24d6c7a3cbd5f0634a5e48400657dd695d /crxid
parentd3ed6d81900766ec53547623ac3e59a537fa2179 (diff)
crxid: initial commitv1.0.0
Based on https://github.com/dsoprea/ChromeIdGenerator/blob/master/README.txt
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