MCPcopy Create free account
hub / github.com/CreditTone/hooker / stringToBase64

Function stringToBase64

js/hook_encryption_algo.js:22–45  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

20var base64EncodeChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
21 base64DecodeChars = new Array((-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), (-1), 62, (-1), (-1), (-1), 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, (-1), (-1), (-1), (-1), (-1), (-1), (-1), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, (-1), (-1), (-1), (-1), (-1), (-1), 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, (-1), (-1), (-1), (-1), (-1));
22function stringToBase64(e) {
23 var r, a, c, h, o, t;
24 for (c = e.length, a = 0, r = ''; a < c;) {
25 if (h = 255 & e.charCodeAt(a++), a == c) {
26 r += base64EncodeChars.charAt(h >> 2),
27 r += base64EncodeChars.charAt((3 & h) << 4),
28 r += '==';
29 break
30 }
31 if (o = e.charCodeAt(a++), a == c) {
32 r += base64EncodeChars.charAt(h >> 2),
33 r += base64EncodeChars.charAt((3 & h) << 4 | (240 & o) >> 4),
34 r += base64EncodeChars.charAt((15 & o) << 2),
35 r += '=';
36 break
37 }
38 t = e.charCodeAt(a++),
39 r += base64EncodeChars.charAt(h >> 2),
40 r += base64EncodeChars.charAt((3 & h) << 4 | (240 & o) >> 4),
41 r += base64EncodeChars.charAt((15 & o) << 2 | (192 & t) >> 6),
42 r += base64EncodeChars.charAt(63 & t)
43 }
44 return r
45}
46function base64ToString(e) {
47 var r, a, c, h, o, t, d;
48 for (t = e.length, o = 0, d = ''; o < t;) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected