File: keys.R

package info (click to toggle)
r-cran-openssl 1.2.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,136 kB
  • sloc: ansic: 2,033; sh: 19; makefile: 5
file content (38 lines) | stat: -rw-r--r-- 1,172 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## ----setup, include=FALSE------------------------------------------------
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = "")
library(openssl)

## ------------------------------------------------------------------------
key <- ec_keygen()
pubkey <- key$pubkey
bin <- write_der(pubkey)
print(bin)

## ------------------------------------------------------------------------
read_pubkey(bin, der = TRUE)

## ------------------------------------------------------------------------
cat(write_pem(pubkey))
cat(write_pem(key, password = NULL))

## ------------------------------------------------------------------------
cat(write_pem(key, password = "supersecret"))

## ------------------------------------------------------------------------
str <- write_ssh(pubkey)
print(str)

## ------------------------------------------------------------------------
read_pubkey(str)

## ------------------------------------------------------------------------
library(jose)
json <- write_jwk(pubkey)
jsonlite::prettify(json)

## ------------------------------------------------------------------------
mykey <- read_jwk(json)
identical(mykey, pubkey)
print(mykey)