R: Encode to base64 or Decode from base64

base64_urlencode {base64url} | R Documentation

## Encode to base64 or Decode from base64

### Description

In contrast to RFC3548, the 62nd character (‘+’) is replaced with ‘-’, the 63rd character (‘/’) is replaced with ‘_’. Furthermore, the encoder does not fill the string with trailing ‘=’. The resulting encoded strings comply to the regular expression pattern “[A-Za-z0-9_-]” and thus are safe to use in URLs or for file names.

### Usage

    base64_urlencode(x)

    base64_urldecode(x)

### Arguments

`x` | [`character(1)`] Character vector to encode or decode.

### Value

[`character`] of the same length as input `x`.

### References

Implementation based on base64 encoder/decoder in the Apache Portable Runtime (APR): https://svn.apache.org/repos/asf/apr/apr/trunk/encoding/apr_base64.c

### Examples

    x = "plain text"
    encoded = base64_urlencode(x)
    decoded = base64_urldecode(encoded)
    print(encoded)
    print(decoded)

[Package base64url version 1.4 Index]