encrypt_file: Encrypt a file

Description Usage Arguments Details Value Examples

View source: R/encrypt_file.R

Description

Encryption and decryption with asymmetric keys is computationally expensive. This is how encrypt works, in order to allow each piece of data in a data frame to be decrypted without compromise of the whole data frame. This works on the presumption that each cell contains less than 245 bytes of data.

Usage

1
2
encrypt_file(.path, crypt_file_name = NULL,
  public_key_path = "id_rsa.pub")

Arguments

.path

Quoted path to file to encrypt.

crypt_file_name

Optional new name to give encrypted file. Must end with ".encrypter.bin".

public_key_path

Quoted path to public key, created with genkeys.

Details

File encryption requires a different approach as files are often larger in size. This function encrypts a file using a a symmetric "session" key and the AES-256 cipher. This key is itself then encrypted using a public key generated using genkeys. In OpenSSL this combination is referred to as an envelope.

Value

The encrypted file is saved.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# This will run:
# Create example file to encrypt
# write.csv(gp, "gp.csv")
# genkeys()
# encrypt_file("gp.csv")

# For CRAN and testing:
## Not run: 
# Run only once in decrypt_file example
temp_dir = tempdir() # temp directory for testing only
genkeys(file.path(temp_dir, "id_rsa"))
write.csv(gp, file.path(temp_dir, "gp.csv"))
encrypt_file(file.path(temp_dir, "gp.csv"), public_key_path = file.path(temp_dir, "id_rsa.pub"))

## End(Not run)

SurgicalInformatics/encryptr documentation built on Nov. 9, 2019, 6:55 p.m.