https://github.com/epicericee/typst-based
A Typst package for encoding and decoding in base64, base32, and base16.
https://github.com/epicericee/typst-based
base16 base32 base64 typst typst-package typst-plugin
Last synced: 7 months ago
JSON representation
A Typst package for encoding and decoding in base64, base32, and base16.
- Host: GitHub
- URL: https://github.com/epicericee/typst-based
- Owner: EpicEricEE
- License: mit
- Created: 2024-07-05T10:49:20.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-11-06T00:01:42.000Z (11 months ago)
- Last Synced: 2025-01-24T05:11:26.310Z (9 months ago)
- Topics: base16, base32, base64, typst, typst-package, typst-plugin
- Language: Typst
- Homepage:
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# based
A package for encoding and decoding in base64, base32, and base16.
## Usage
The package comes with three submodules: `base64`, `base32`, and `base16`. All of them have an `encode` and `decode` function. The package also provides the function aliases
- `encode64` / `decode64`,
- `encode32` / `decode32`, and
- `encode16` / `decode16`.Both base64 and base32 allow you to choose whether to use padding for encoding via the `pad` parameter, which is enabled by default. Base64 also allows you to encode with the URL-safe alphabet by enabling the `url` parameter, while base32 allows you to encode or decode with the "extended hex" alphabet via the `hex` parameter. Both options are disabled by default. The base16 encoder uses lowercase letters, the decoder is case-insensitive.
You can encode strings, arrays and bytes. The `encode` function will return a string, while the `decode` function will return bytes.
## Example
```typ
#import "@preview/based:0.2.0": base64, base32, base16#table(
columns: 3,
table.header[*Base64*][*Base32*][*Base16*],raw(base64.encode("Hello world!")),
raw(base32.encode("Hello world!")),
raw(base16.encode("Hello world!")),str(base64.decode("SGVsbG8gd29ybGQh")),
str(base32.decode("JBSWY3DPEB3W64TMMQQQ====")),
str(base16.decode("48656C6C6F20776F726C6421"))
)
```