MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / binb2b64

Function binb2b64

scripts/passwordGenerator.js:105–121  ·  view source on GitHub ↗
(binarray)

Source from the content-addressed store, hash-verified

103 }
104
105 function binb2b64(binarray) {
106 var tab =
107 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
108 var str = "";
109 for (var i = 0; i < binarray.length * 4; i += 3) {
110 var triplet =
111 (((binarray[i >> 2] >> (8 * (3 - (i % 4)))) & 0xff) << 16) |
112 (((binarray[(i + 1) >> 2] >> (8 * (3 - ((i + 1) % 4)))) & 0xff) <<
113 8) |
114 ((binarray[(i + 2) >> 2] >> (8 * (3 - ((i + 2) % 4)))) & 0xff);
115 for (var j = 0; j < 4; j++) {
116 if (i * 8 + j * 6 > binarray.length * 32) str += b64pad;
117 else str += tab.charAt((triplet >> (6 * (3 - j))) & 0x3f);
118 }
119 }
120 return str;
121 }
122
123 function doIt() {
124 var master = prompt(

Callers 1

b64_sha1Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected