summaryrefslogtreecommitdiff
path: root/WebInterface/NodeJSServer/src/modules/hash.js
diff options
context:
space:
mode:
authorTrueKuehli <rctcoaster2000@hotmail.de>2018-11-27 12:16:33 +0100
committerTrueKuehli <rctcoaster2000@hotmail.de>2018-11-27 12:16:33 +0100
commit9f0b255f32dfa81bffe75f89335a78a659b4ce6a (patch)
treec4345ef6f98fee35f326bc06c29cada542a78e43 /WebInterface/NodeJSServer/src/modules/hash.js
parenta653a4efc60ef0bbc18e65cb11a4bd8c06c7ad5c (diff)
Reworked the code, but currently unable to test, so bugs are bound to be in there
Will test it sometime later. There also might still be stuff, that has yet to be reworked.
Diffstat (limited to 'WebInterface/NodeJSServer/src/modules/hash.js')
-rw-r--r--WebInterface/NodeJSServer/src/modules/hash.js20
1 files changed, 0 insertions, 20 deletions
diff --git a/WebInterface/NodeJSServer/src/modules/hash.js b/WebInterface/NodeJSServer/src/modules/hash.js
deleted file mode 100644
index 3abcc21..0000000
--- a/WebInterface/NodeJSServer/src/modules/hash.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Creates Base64 String with SHA-256 Hash of given string
- */
-String.prototype.getHash = async function() {
- let data = new ArrayBuffer(this.length * 2);
- let bufferView = new Uint16Array(data);
- for (let i = 0; i < this.length; i++) {
- bufferView[i] = this.charCodeAt(i);
- }
-
- let encrypted = await crypto.subtle.digest('SHA-256', bufferView);
- let byteArray = new Uint8Array(encrypted);
- let base64String = '';
-
- for (let byte of byteArray) {
- base64String += String.fromCharCode(byte);
- }
-
- return btoa(base64String);
-};