decrypt_mykeys: Function that decrypt encrypted content

Description Usage Arguments Details Value Examples

View source: R/decrypt_mykeys.R

Description

Cryptography facility

[Stable]

Usage

1
decrypt_mykeys(path_encrypted_content, path_private_key)

Arguments

path_encrypted_content
  • path to the encrypted content of the API key

path_private_key
  • path to the private RSA key, should be without password

Details

It is possible to generate private/public key pair using R-Studio Project Options Menu. Alternatively possible to use 'openssl' R package

Value

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(dplyr)
library(magrittr)
library(openssl)
library(readr)

path_ssh <- normalizePath(tempdir(),winslash = "/")
rsa_keygen() %>% write_pem(path = file.path(path_ssh, 'id_api'))
# extract and write your public key
read_key(file = file.path(path_ssh, 'id_api'), password = "") %>%
`[[`("pubkey") %>% write_pem(path = file.path(path_ssh, 'id_api.pub'))

path_private_key <- file.path(path_ssh, "id_api")
path_public_key <- file.path(path_ssh, "id_api.pub")

#encrypting string 'my_key'...
encrypt_api_key(api_key = 'my_key', enc_name = 'api_key.enc.rds',path_ssh = path_ssh)

#encrypted content
out <- read_rds(file.path(path_ssh, "api_key.enc.rds"))

# Consumer API keys
ConsumerAPIkeys <- decrypt_mykeys(path_encrypted_content = file.path(path_ssh,
                                  'api_key.enc.rds'),
                                  path_private_key = path_private_key)

lazytrade documentation built on Dec. 16, 2021, 1:06 a.m.