MCPcopy Create free account
hub / github.com/BlueprintLabIO/prompt-injector / encodeBase64

Function encodeBase64

core/src/utils/encoding.ts:9–19  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

7 * Works in both Node.js and browser environments
8 */
9export function encodeBase64(text: string): string {
10 if (typeof Buffer !== 'undefined') {
11 // Node.js environment
12 return Buffer.from(text).toString('base64');
13 } else {
14 // Browser environment - modern approach
15 const encoder = new TextEncoder();
16 const data = encoder.encode(text);
17 return btoa(String.fromCharCode(...Array.from(data)));
18 }
19}
20
21/**
22 * Encode string to hexadecimal

Callers 1

generateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected