Base64 encoding and decoding

Share:

Description

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).

Usage

1
2
3
encode64(x, char62 = "-", char63 = "_")

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

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

Examples

1
2
3
4
5
6
7
x <- encode64("hello")
x
decode64(x)

# Encoding things into filename-safe strings is the reason for
# this function:
encode64("unlikely/to be @ valid filename")