decrypt_mykeys: Function that decrypt encrypted content

View source: R/decrypt_mykeys.R

decrypt_mykeysR Documentation

Function that decrypt encrypted content

Description

Cryptography facility

[Stable]

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

Details

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

Value

  • a string with decrypted key

Examples


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 Sept. 12, 2024, 9:36 a.m.