summaryrefslogtreecommitdiff
path: root/static/main.js
diff options
context:
space:
mode:
authormarc <mlasch@mailbox.org>2019-08-15 14:15:47 +0200
committermarc <mlasch@mailbox.org>2019-08-15 14:15:47 +0200
commit5f60e7ba37e50964827e59f2a9079408bd0113b8 (patch)
treeccb7423c806a5ca7c2a7e64f3874ea391d5bbc46 /static/main.js
parente4e413ede34a2ae306ddd130324435d0e735f064 (diff)
downloadinfluxdb-guard-5f60e7ba37e50964827e59f2a9079408bd0113b8.tar.gz
influxdb-guard-5f60e7ba37e50964827e59f2a9079408bd0113b8.zip
Added random token generator button
Diffstat (limited to 'static/main.js')
-rw-r--r--static/main.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/static/main.js b/static/main.js
new file mode 100644
index 0000000..e00efd4
--- /dev/null
+++ b/static/main.js
@@ -0,0 +1,12 @@
+// Generate random token string
+
+const KEY_LENGTH = 20;
+const ALPHABET_BASE58 = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
+
+function genToken() {
+ const rand_buffer = Array.from(window.crypto.getRandomValues(new Uint32Array(KEY_LENGTH)));
+ const rand_chars = rand_buffer.map(elem => ALPHABET_BASE58.charAt(Math.round(elem/4294967295*58)));
+ const token = rand_chars.join("");
+
+ document.getElementById("tokenField").value = token;
+}