/** * Base64 / binary data / UTF-8 strings utilities * * It ensures that UTF-8 characters are used when encoding to Base64. * * Based on code of: * * @module * * @example Encode string to Base64 * ```ts * import { encodeBase64 } from "apprt-core/base64"; * * const base64str = encodeBase64("hello world"); * // base64str === "aGVsbG8gd29ybGQ=" * ``` * * @example Decode Base64 string * ```ts * import { decodeBase64 } from "apprt-core/base64"; * * const str = decodeBase64("aGVsbG8gd29ybGQ="); * // str === "hello world" * ``` */ /** * Encodes a string into a Base64-encoded string. * The string is first converted into a UTF-8 array and then encoded as Base64 string. * @param input a string to encode. * @returns Base64-encoded input */ declare function encodeBase64(input: string): string; /** * Decodes a Base64 string into the raw string. * The Base64 string is first decoded into a UTF-8 array and then converted into a string. * @param input Base64 string. * @returns decoded input. */ declare function decodeBase64(input: string): string; /** * Converts a Base64 string into a UTF-8 array. * * If your aim is to build a buffer of 16-bit / 32-bit / 64-bit raw data, * use the blocksSize argument, which is the number of bytes * of which the uint8Array.buffer.bytesLength property must result a multiple. * - 1 or omitted for ASCII, binary strings * (i.e., a string in which each character in the string is treated as a byte of binary data) * or UTF-8-encoded strings, * - 2 for UTF-16 strings, * - 4 for UTF-32 strings * @param base64Input the base64 input * @param blocksSize 1, 2 or 4 see above. * @returns decoded bytes. */ declare function base64DecodeToUtf8Arr(base64Input: string, blocksSize?: number): Uint8Array; /** * Encodes a byte array into a Base64 string representation. * @param utf8Array array of bytes. * @returns Base64 string */ declare function base64EncodeUtf8Arr(utf8Array: Uint8Array): string; /** * Converts a UTF-8 byte array into a string. * @param utf8Array byte array. * @returns string. */ declare function utf8ArrToStr(utf8Array: Uint8Array): string; /** * Converts a string into a UTF-8 byte array. * @param input string to encode as UTF-8 bytes. * @returns UTF-8 byte array. */ declare function strToUtf8Arr(input: string): Uint8Array; export { base64DecodeToUtf8Arr, base64EncodeUtf8Arr, decodeBase64, encodeBase64, strToUtf8Arr, utf8ArrToStr };