2022-09-09 06:21:08 +03:00
|
|
|
import { getBytes, getBytesCopy } from "./data.js";
|
2022-09-05 23:14:43 +03:00
|
|
|
|
|
|
|
import type { BytesLike } from "./data.js";
|
|
|
|
|
|
|
|
|
2022-09-09 10:37:38 +03:00
|
|
|
/**
|
|
|
|
* Decodes the base-64 encoded %%base64Data%%.
|
|
|
|
*/
|
|
|
|
export function decodeBase64(base64Data: string): Uint8Array {
|
|
|
|
return getBytesCopy(Buffer.from(base64Data, "base64"));
|
2022-09-05 23:14:43 +03:00
|
|
|
};
|
|
|
|
|
2022-09-09 10:37:38 +03:00
|
|
|
/**
|
|
|
|
* Encodes %%data%% as base-64 encoded data.
|
|
|
|
*/
|
2022-09-05 23:14:43 +03:00
|
|
|
export function encodeBase64(data: BytesLike): string {
|
2022-09-09 06:21:08 +03:00
|
|
|
return Buffer.from(getBytes(data)).toString("base64");
|
2022-09-05 23:14:43 +03:00
|
|
|
}
|