read.aes: Read Encrypted Data.

View source: R/readEncryptedData.R

read.aesR Documentation

Read Encrypted Data.

Description

Read data from encrypted file.

Usage

read.aes(filename, key)

Arguments

filename

Location of encrypted data.

key

Encryption key.

Details

Reads data from an encrypted file. To write an data to an encrypted file, see write.aes.

Value

Unencrypted data.

See Also

https://stackoverflow.com/questions/25318800/how-do-i-read-an-encrypted-file-from-disk-with-r/25321586#25321586

Other encrypted: write.aes()

Examples


# Location of Encryption Key on Local Computer (where only you should have access to it)
#encryptionKeyLocation <- file.path(getwd(), "/encryptionKey.RData",
#  fsep = "") #Can change to a different path, e.g.: "C:/Users/[USERNAME]/"

# Generate a Temporary File Path for Encryption Key
encryptionKeyLocation <- tempfile(fileext = ".RData")

# Generate Encryption Key
key <- as.raw(sample(1:16, 16))

# Save Encryption Key
save(key, file = encryptionKeyLocation)

# Specify Credentials
credentials <- "Insert My Credentials Here"

# Generate a Temporary File Path for Encrypted Credentials
encryptedCredentialsLocation <- tempfile(fileext = ".txt")

# Save Encrypted Credentials
#write.aes(
#  df = credentials,
#  filename = file.path(getwd(), "/encrypytedCredentials.txt", fsep = ""),
#  key = key) # Change the file location to save this on the lab drive

write.aes(
  df = credentials,
  filename = encryptedCredentialsLocation,
  key = key)

rm(credentials)
rm(key)

# Read and Unencrypt the Credentials Using the Encryption Key
load(encryptionKeyLocation)

#credentials <- read.aes(
#  filename = file.path(getwd(), "/encrypytedCredentials.txt", fsep = ""),
#  key = key)

credentials <- read.aes(
  filename = encryptedCredentialsLocation,
  key = key)



petersenlab documentation built on May 29, 2024, 8:34 a.m.