Package 'b32'

Title: Fast and Vectorized Base32 Encoding
Description: Fast, dependency free, and vectorized base32 encoding and decoding. 'b32' supports the Crockford, Z, RFC 4648 lower, hex, and lower hex alphabets.
Authors: Josiah Parry [aut, cre] (ORCID: <https://orcid.org/0000-0001-9910-865X>)
Maintainer: Josiah Parry <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-05-24 09:13:06 UTC
Source: https://github.com/extendr/b32

Help Index


Base32 Encode and Decode

Description

Base32 Encode and Decode

Usage

encode(x, alphabet = "crockford", padded = TRUE)

decode(x, alphabet = "crockford", padded = TRUE)

decode_as_string(x, alphabet = "crockford", padded = TRUE)

Arguments

x

for encode(), must be either a character or raw vector. For decode(), a character vector.

alphabet

default '"crockford". The base32 encoding alphabet to use. Must be one of "crockford", "rfc4648", "rfc4648lower", "rfc4648hex", "rfc4648hexlower", or "z".

padded

default TRUE. Appends = to ensure that the final encoded chunk is 8 blocks of characters.

Details

decode() returns a blob object which is a list of raw vectors. If an error is encountered in decode() the result will be an NA.

Value

decode() returns a blob object. encode() returns a character vector. decode_as_string() returns a character vector.

Examples

encode("hello")
encode("hello", padded = FALSE)
encode("hello", alphabet = "rfc4648")

# Decode base32 string
decode("NBSWY3DPEBLW64TMMQ======")
decode_as_string("NBSWY3DPEBLW64TMMQ======")
decode("NBSWY3DPEBLW64TMMQ", padded = FALSE)