MCPcopy Create free account
hub / github.com/backnotprop/plannotator / bytesToBase64url

Function bytesToBase64url

packages/shared/crypto.ts:81–91  ·  view source on GitHub ↗
(bytes: Uint8Array)

Source from the content-addressed store, hash-verified

79// --- Helpers ---
80
81function bytesToBase64url(bytes: Uint8Array): string {
82 // Loop to avoid RangeError on large payloads (same approach as compress.ts)
83 let binary = '';
84 for (let i = 0; i < bytes.length; i++) {
85 binary += String.fromCharCode(bytes[i]);
86 }
87 return btoa(binary)
88 .replace(/\+/g, '-')
89 .replace(/\//g, '_')
90 .replace(/=/g, '');
91}
92
93function base64urlToBytes(b64: string): Uint8Array {
94 const base64 = b64.replace(/-/g, '+').replace(/_/g, '/');

Callers 1

encryptFunction · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected