Learn R Programming

b32 (version 0.1.0)

encode: 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)

Value

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

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.

Examples

Run this code
encode("hello")
encode("hello", padded = FALSE)
encode("hello", alphabet = "rfc4648")

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

Run the code above in your browser using DataLab