Skip to contents

Returns the same closure object as digest::AES(): $encrypt(text), $decrypt(ciphertext, raw = FALSE), $IV(), $block_size(), $key_size(), $mode(). ECB, CBC (optionally PKCS#7-padded), CFB and CTR modes over AES-128/192/256.

Usage

morie_aes(
  key,
  mode = c("ECB", "CBC", "CFB", "CTR"),
  IV = NULL,
  padding = FALSE
)

Arguments

key

raw key of 16, 24 or 32 bytes.

mode

"ECB", "CBC", "CFB" or "CTR".

IV

raw initialisation vector (16 bytes) for the chained modes.

padding

pad CBC input to whole blocks.

Value

an object of class AES.

Examples

key <- as.raw(1:16)
aes <- morie_aes(key, mode = "ECB")
ct <- aes$encrypt(charToRaw("0123456789abcdef"))
aes$decrypt(ct)
#> [1] "0123456789abcdef"