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.
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")
)
the file you want to encrypt
optional, the output path
optional, the encryption key
optional, print the encryption key to the console
optional, write a key file in the same directory
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.
The key used to encrypt the file as an invisible raw vector.
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.
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.