1const keyset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; 2 3export function encodeNoWrap(input: string): string { 4 let output = ''; 5 let i = 0; 6 7 do { 8 const chr1 = input.charCodeAt(i++); 9 const chr2 = input.charCodeAt(i++); 10 const chr3 = input.charCodeAt(i++); 11 12 const enc1 = chr1 >> 2; 13 const enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); 14 let enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); 15 let enc4 = chr3 & 63; 16 if (isNaN(chr2)) { 17 enc3 = 64; 18 enc4 = 64; 19 } else if (isNaN(chr3)) { 20 enc4 = 64; 21 } 22 23 output = 24 output + 25 keyset.charAt(enc1) + 26 keyset.charAt(enc2) + 27 keyset.charAt(enc3) + 28 keyset.charAt(enc4); 29 } while (i < input.length); 30 31 return output; 32} 33