lazytrade (version 0.4.0)

decrypt_mykeys: Function that decrypt encrypted content

Description

Function that decrypt encrypted content

Usage

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

Value

- a string with decrypted key

Details

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

Examples

Run this code
# NOT RUN {
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)


# }

Run the code above in your browser using DataCamp Workspace