Learn R Programming

base64url (version 1.4)

base32_encode: Encode to base32 or Decode from base32

Description

Simple RFC4648 base32 encoder/decoder. Pads with “=”.

Usage

base32_encode(x, use.padding = FALSE)

base32_decode(x, use.padding = FALSE)

Arguments

x

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

use.padding

[logical(1)] If TRUE, base32_encode returns a string whose length is a multiple of 8, padded with trailing “=” if required. base32_decode expects such a string unless this is set to FALSE (default). The internal algorithm currently works with padding, thus it is faster to set this to TRUE.

Value

[character] of the same length as input x.

References

Implementation based on base32 encoder/decoder in the GNU lib: https://www.gnu.org/software/gnulib/.

Examples

Run this code
# NOT RUN {
x = "plain text"
encoded = base32_encode(x)
decoded = base32_decode(encoded)
print(encoded)
print(decoded)
# }

Run the code above in your browser using DataLab