Base64 encoding. By default uses the RFC 4648 dialect (file/url encoding) where characters 62 and 63 are "-" and "_". Pass in "+" and "/" to get the RFC 1421 variant (as in other R packages that do base64 encoding).

encode64(x, char62 = "-", char63 = "_", pad = TRUE)

decode64(x, char62 = "-", char63 = "_", error = TRUE)

Arguments

x

A string or vector of strings to encode/decode

char62

Character to use for the 62nd index

char63

Character to use for the 63rd index

pad

Logical, indicating if strings should be padded with = characters (as RFC 4648 requires)

error

Throw an error if the decoding fails. If FALSE then NA_character_ values are returned for failures.

Examples

x <- encode64("hello") x
#> [1] "aGVsbG8="
decode64(x)
#> [1] "hello"
# Encoding things into filename-safe strings is the reason for # this function: encode64("unlikely/to be @ valid filename")
#> [1] "dW5saWtlbHkvdG8gYmUgQCB2YWxpZCBmaWxlbmFtZQ=="