encrypt_html_file {encryptedRmd}R Documentation

Encrypt an html file

Description

This function takes an html file, encrypts the complete file using sodium::data_encrypt and a given key. It then injects the encrypted content into an html template that contains the sodium decryption code compiled to javascript. The resulting file is fully self contained as it can decrypt itself. When the user enters the correct key, the DOM of the html files gets replaced with the initially encrypted html file.

Usage

encrypt_html_file(
  path,
  output_path = paste0(path, ".enc.html"),
  key = sodium::random(32L),
  message_key = TRUE,
  write_key_file = FALSE,
  output_template_path = system.file("html-template.html", package = "encryptedRmd")
)

Arguments

path

the file you want to encrypt

output_path

optional, the output path

key

optional, the encryption key

message_key

optional, print the encryption key to the console

write_key_file

optional, write a key file in the same directory

output_template_path

a path to the output template. The output template needs have the same html form elements (same ids) and the same placeholders as the default template. Everything else can be customized.

Details

Warning: You are using this at your own risk. Make sure your encryption key is strong enough. For serious use cases, please also review the code of the functions. Any feedback is appreciated. This is an early package version.

Value

The key used to encrypt the file as an invisible raw vector.

References

The package follows the same approach as the node module self-decrypting-html-page. The decryption code is based on a number of great node modules. All licenses are also bundled with each encrypted html file.


[Package encryptedRmd version 0.2.1 Index]