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

Function encodeBase32

encoding/unstable_base32.ts:106–122  ·  view source on GitHub ↗
(
  input: string | Uint8Array_ | ArrayBuffer,
  options: Base32Options = {},
)

Source from the content-addressed store, hash-verified

104 * ```
105 */
106export function encodeBase32(
107 input: string | Uint8Array_ | ArrayBuffer,
108 options: Base32Options = {},
109): string {
110 options.alphabet ??= "base32";
111 if (typeof input === "string") {
112 input = new TextEncoder().encode(input) as Uint8Array_;
113 } else if (input instanceof ArrayBuffer) {
114 input = new Uint8Array(input);
115 }
116 const [output, i] = detach(
117 input as Uint8Array_,
118 calcSizeBase32((input as Uint8Array_).length),
119 );
120 encode(output, i, 0, alphabet[options.alphabet], padding);
121 return new TextDecoder().decode(output);
122}
123
124/**
125 * `encodeIntoBase32` takes an input source and encodes it as base32 into the

Callers

nothing calls this directly

Calls 3

detachFunction · 0.90
calcSizeBase32Function · 0.90
encodeFunction · 0.90

Tested by

no test coverage detected