Title: | Encrypt HTML Files Using 'staticrypt' |
---|---|
Description: | Provides a convenient interface to the 'staticrypt' by Robin Moisson <https://github.com/robinmoisson/staticrypt>---'Node.js' package for adding a password protection layer to static HTML pages. This package can be integrated into the post-render process of 'quarto' documents to secure them with a password. |
Authors: | Nikita Tkachenko [aut, cre, cph] |
Maintainer: | Nikita Tkachenko <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-12-01 08:36:51 UTC |
Source: | CRAN |
Checks if Node.js, npm, and Staticrypt are available on your system.
check_system()
check_system()
This function verifies that Node.js, npm, and Staticrypt are installed and available in the system PATH. It will attempt to install Staticrypt if it is not found.
Logical. Returns TRUE
if all requirements are met.
Installs Staticrypt globally using npm if it is not already installed. Requires Node.js and npm to be installed on your system.
install_staticrypt(force = FALSE)
install_staticrypt(force = FALSE)
force |
Logical. If |
This function checks if Node.js and npm are available, then installs
Staticrypt globally using npm. If force
is FALSE
, it prompts the user
for confirmation before proceeding with the installation.
Logical. Returns TRUE
if installation was successful, FALSE
otherwise.
This function is an R wrapper for the Staticrypt CLI tool. It allows users to encrypt or decrypt files using various customizable options, includes type checking for each argument, offers the option to print the resulting command without executing it, and allows the inclusion of a user-specified string.
staticryptr( files, directory = NULL, recursive = FALSE, password = NULL, short = FALSE, decrypt = FALSE, remember = NULL, salt = NULL, share = NULL, share_remember = FALSE, config = NULL, template = NULL, template_button = NULL, template_color_primary = NULL, template_color_secondary = NULL, template_instructions = NULL, template_error = NULL, template_placeholder = NULL, template_remember = NULL, template_title = NULL, template_toggle_hide = NULL, template_toggle_show = NULL, print_cmd = FALSE, user_string = NULL )
staticryptr( files, directory = NULL, recursive = FALSE, password = NULL, short = FALSE, decrypt = FALSE, remember = NULL, salt = NULL, share = NULL, share_remember = FALSE, config = NULL, template = NULL, template_button = NULL, template_color_primary = NULL, template_color_secondary = NULL, template_instructions = NULL, template_error = NULL, template_placeholder = NULL, template_remember = NULL, template_title = NULL, template_toggle_hide = NULL, template_toggle_show = NULL, print_cmd = FALSE, user_string = NULL )
files |
Character. One or more filenames to encrypt/decrypt. |
directory |
Character. Directory where the generated files will be saved (default: NULL). |
recursive |
Boolean. Whether to recursively encrypt the input directory (default: FALSE). |
password |
Character. Password for encryption (default: NULL, prompts if empty). |
short |
Boolean. Hide "short password" warning (default: FALSE). |
decrypt |
Boolean. Flag to decrypt files (default: FALSE). |
remember |
Integer. Expiration in days for "Remember me" checkbox (default: NULL). |
salt |
Character. 32-character hexadecimal string used as salt (default: NULL). |
share |
Character. URL for auto-decrypting link (default: NULL). |
share_remember |
Boolean. Auto-enable "Remember me" in the share link (default: FALSE). |
config |
Character. Path to the config file (default: NULL). |
template |
Character. Path to custom HTML template (default: NULL). |
template_button |
Character. Label for the decrypt button (default: NULL). |
template_color_primary |
Character. Primary color for the button (default: NULL). |
template_color_secondary |
Character. Secondary color for the background (default: NULL). |
template_instructions |
Character. Special instructions for the user (default: NULL). |
template_error |
Character. Error message on wrong password (default: NULL). |
template_placeholder |
Character. Placeholder for password input (default: NULL). |
template_remember |
Character. Label for "Remember me" checkbox (default: NULL). |
template_title |
Character. Title for the HTML page (default: NULL). |
template_toggle_hide |
Character. Alt text for hiding the password (default: NULL). |
template_toggle_show |
Character. Alt text for showing the password (default: NULL). |
print_cmd |
Boolean. Whether to print the resulting command instead of executing it (default: FALSE). |
user_string |
Character. A user-specified string to be appended to the command (default: NULL). |
Executes the Staticrypt CLI with the specified options or prints the command if print_cmd
is TRUE
.
# Encrypt a file with a password # `print_cmd = TRUE` Only outputs the command to be passed to `system()` staticryptr( "index.html", password = "yourpassword", print_cmd = TRUE ) # Decrypt a file (assuming you have the correct configuration) staticryptr( "index.html", decrypt = TRUE, print_cmd = TRUE ) # Encrypt multiple files with custom options staticryptr( files = c("page1.html", "page2.html"), password = "securepassword", template = "custom_template.html", template_color_primary = "#3498db", template_instructions = "Enter the password to access the page.", print_cmd = TRUE ) # Encrypt a directory recursively staticryptr( files = "_output/", directory = ".", password = "yourverylongpassword", short = TRUE, recursive = TRUE, print_cmd = TRUE )
# Encrypt a file with a password # `print_cmd = TRUE` Only outputs the command to be passed to `system()` staticryptr( "index.html", password = "yourpassword", print_cmd = TRUE ) # Decrypt a file (assuming you have the correct configuration) staticryptr( "index.html", decrypt = TRUE, print_cmd = TRUE ) # Encrypt multiple files with custom options staticryptr( files = c("page1.html", "page2.html"), password = "securepassword", template = "custom_template.html", template_color_primary = "#3498db", template_instructions = "Enter the password to access the page.", print_cmd = TRUE ) # Encrypt a directory recursively staticryptr( files = "_output/", directory = ".", password = "yourverylongpassword", short = TRUE, recursive = TRUE, print_cmd = TRUE )