tests/testthat/test_my_key.R

context("Test default user key")

# Read secret key and public key

test_that("reading protected keys", {
  sk1 <- rsa_keygen()
  pk1 <- as.list(sk1)$pubkey
  tmp_key <- tempfile()
  tmp_pubkey <- tempfile()
  write_pem(sk1, tmp_key, password = NULL)
  write_pem(pk1, tmp_pubkey)

  # Test default private key
  Sys.setenv("USER_KEY" = tmp_key)
  expect_equal(sk1, my_key())
  expect_equal(pk1, my_pubkey())
})

Try the openssl package in your browser

Any scripts or data that you put into this service are public.

openssl documentation built on Sept. 26, 2023, 1:09 a.m.