MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / decode

Function decode

packages/ui-default/utils/base64.js:32–57  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

30 },
31
32 decode(input) {
33 let output = '';
34 let chr1;
35 let chr2;
36 let chr3;
37 let enc1;
38 let enc2;
39 let enc3;
40 let enc4;
41 let i = 0;
42 input = input.replace(/[^A-Za-z0-9+/=]/g, '');
43 while (i < input.length) {
44 enc1 = this._keyStr.indexOf(input.charAt(i++));
45 enc2 = this._keyStr.indexOf(input.charAt(i++));
46 enc3 = this._keyStr.indexOf(input.charAt(i++));
47 enc4 = this._keyStr.indexOf(input.charAt(i++));
48 chr1 = (enc1 << 2) | (enc2 >> 4);
49 chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
50 chr3 = ((enc3 & 3) << 6) | enc4;
51 output += String.fromCharCode(chr1);
52 if (enc3 !== 64) output += String.fromCharCode(chr2);
53 if (enc4 !== 64) output += String.fromCharCode(chr3);
54 }
55 output = Base64._utf8Decode(output);
56 return output;
57 },
58
59 _utf8Encode(string) {
60 string = string.replace(/\r\n/g, '\n');

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected