remove unnecesary const from parse and added comment to binarytoarray

This commit is contained in:
Bit Borealis 2022-08-12 01:54:01 +00:00
parent 848e0c0e03
commit 03969051a4
Signed by: theotheroracle
GPG Key ID: 2D816A2DCA6E5649
1 changed files with 3 additions and 9 deletions

View File

@ -1,10 +1,3 @@
const baseUrl: string = "https://envs.sh"
const id: string = "QnK" // < unicode >
const key: string = "LhBRttf+oI/PNHyTBrPa7HGDK/uC9fcMkGGgz63zT4Y=" // 32 bytes b64
const completeUrl: string = baseUrl + "/" + id + ".bin#" + key
console.log(completeUrl);
const urlObj:URL = new URL(completeUrl);
/** will return a tuple of the key and id if valid
* 1 if no id ( creator )
* 2 if encryption key is missing / wrong length
@ -30,6 +23,9 @@ function validUrl(url: URL): [string,Uint8Array] | number {
}
}
/**
* will convert a binary string to a Uint8Array
*/
function binaryToArray(raw: string): Uint8Array {
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
@ -39,5 +35,3 @@ function binaryToArray(raw: string): Uint8Array {
}
return array;
}
console.log(validUrl(urlObj));