Learn R Programming

nanonext (version 0.7.3)

base64enc: Base64 Encode / Decode

Description

Encodes / decodes a character string or arbitrary R object to base64 encoding.

Usage

base64enc(x, convert = TRUE)

base64dec(x, convert = TRUE)

Value

A raw vector or character string depending on 'convert'.

Arguments

x

an object.

convert

[default TRUE] logical value whether to convert the output to a character string or keep as a raw vector. Supplying a non-logical value will error.

Details

For encoding: a raw vector is encoded directly, a scalar character string is translated to raw before encoding, whilst all other objects are serialised first.

The result of encoding or decoding is always a raw vector, which is translated to a character string if 'convert' is TRUE, or returned directly if 'convert' is FALSE.

Set 'convert' to FALSE when decoding a raw vector or serialised object, which may be further passed to unserialize.

Examples

Run this code
base64enc("hello world!")
base64dec(base64enc("hello world!"))

base64enc("hello world!", convert = FALSE)
base64dec(base64enc("hello world!", convert = FALSE))

base64enc(data.frame())
unserialize(base64dec(base64enc(data.frame()), convert = FALSE))

Run the code above in your browser using DataLab