MCPcopy Create free account
hub / github.com/denoland/std / encodeBase32

Function encodeBase32

encoding/base32.ts:54–65  ·  view source on GitHub ↗
(data: ArrayBuffer | Uint8Array | string)

Source from the content-addressed store, hash-verified

52 * ```
53 */
54export function encodeBase32(data: ArrayBuffer | Uint8Array | string): string {
55 if (typeof data === "string") {
56 data = new TextEncoder().encode(data) as Uint8Array_;
57 } else if (data instanceof ArrayBuffer) data = new Uint8Array(data).slice();
58 else data = data.slice();
59 const [output, i] = detach(
60 data as Uint8Array_,
61 calcSizeBase32((data as Uint8Array_).length),
62 );
63 encode(output, i, 0, alphabet, padding);
64 return new TextDecoder().decode(output);
65}
66
67/**
68 * Decodes a base32-encoded string.

Callers 3

fnFunction · 0.90

Calls 4

detachFunction · 0.90
calcSizeBase32Function · 0.90
encodeFunction · 0.90
sliceMethod · 0.45

Tested by

no test coverage detected