Code Monkey home page Code Monkey logo

encryptedrmd's Introduction

lifecycle CRAN status R build status

Password protected html markdown documents

Self-encrypt html markdown reports using libsodium. The package lets you password protect markdown html documents and share them with others securely. The code needed to decrypt the file is bundled into the exported html file, which makes the resulting file fully self contained.

Use at your own risk. Feedback and bug reports very welcome!

Installation

install.packages("encryptedRmd")
remotes::install_github("dirkschumacher/encryptedRmd")

Functions

Encrypt html files

library(encryptedRmd)
encrypt_html_file("devel/example/test.html", output_path = "docs/test.encrypted.html")
#> The key to your file is: f5c8c13752cf4e8cc59b59e9f96279ceb6836fc8ce957e55e232724dd80c318f
#> Your file has been encrypted and saved at docs/test.encrypted.html

You can take a look at the exported file here and use the key printed above to decrypt it.

Encrypted rmarkdown html format

---
title: "test"
output: encryptedRmd::encrypted_html_document
---

See here for an example. After knitting, the document is encrypted with a random key and the file is stored in the same directory together with the key.

Inspiration

Inspired and based on the work by @derhuerst on self encrypting html pages.

License

MIT

Development

In devel/r-encrypted-html-template the code to generate the javascript file is contained. In order to update the template, you have to run the following:

  • In devel/r-encrypted-html-template run npm run build. This creates a new version of the template and copies it to devel/html-template.js. It also creates a file called JSLICENSES.txt that contains all licenses of used node packages.
  • In devel run combine.R. This generates the file report template and copies it to inst/html-template.html. This template is then used within the R package to generate encrypted html files.

encryptedrmd's People

Contributors

dependabot[bot] avatar dirkschumacher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

encryptedrmd's Issues

Release encryptedRmd 0.2.0

Prepare for release:

  • Check that description is informative
  • Check licensing of included files
  • devtools::build_readme()
  • usethis::use_cran_comments()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • Update cran-comments.md
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • usethis::use_news_md()
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Update install instructions in README
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

visNetwork htmlwidget are not displayed

Hi, this is a very useful package!
When I use it with a htmlwidget created with the visNetwork package the widget is not displayed in the browser when decrypted. Short example below.

---
title: "test_enrcrypytedRmd"
output: encryptedRmd::encrypted_html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r results='asis'}
library(visNetwork)
nodes <- data.frame(id = 1:3)
edges <- data.frame(from = c(1,2), to = c(1,3))

visNetwork(nodes, edges)
```

encrypt with a folder

In most cases .Rmd is self including, so if you insert an image, it will use data URI scheme. That means everything is inside one .html file, so an encrypting/decrypting process with encryptedRmd goes well.

There are also possibility to have relative paths, so an encrypting/decrypting process with encryptedRmd goes well, but files with relative paths are not included in it.

Here is an example.

I used the version 0.2.09

Is it possible to run encrypt_html() function with a folder?

ggplot graphs disappear in encrypted HTML file

I'm able to encrypt an HTML file using encryptedRmd:

library(encryptedRmd)

path = '//R_Scripts/test.html'

encrypt_html_file(
  path,
  output_path = paste0(path, ".enc.html")
)

The encryption works, and I can access the new encrypted HTML. However, none of the ggplots show up in the encrypted version. Tables with data do show up. The test.html document has ggplots that appear perfectly.

Thanks!

Support PDFs

With a JS pdf viewer like Mozilla's pdf.js that would be possible.

Custom decryption pages

Could it be possible to specify a custom decryption page? This would enable people to provide:

  • Different languages
  • Contact details
  • Branding

Superb package, I'm really looking forward to using it.

Open html directly

Hi, great package! Is there a way to add an option after entering the key, so it opens the html to the current browser page rather than downloading the html file?

Security audit

It would be great if another pair of eyes could look at the security of the package. In particular the encryption.

Relevant lines are here (only 3: key, nonce and encrypt):

encrypt_html_file <- function(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")) {
stopifnot(file.exists(path), is.raw(key), length(key) >= 32L)
content <- charToRaw(readr::read_file(path))
nonce <- sodium::random(24L)
encrypted_content <- sodium::data_encrypt(content, key, nonce)

For decryption, the JS code is in devel. However IMHO encryption is the most critical part. The JS code is only used for decryption purposes.

R crashing using encrypt_html_file

Hi,

When I run encrypt_html_file with the file path to the html doc I want to protect, R immediately crashes. I've tried with the CRAN version and GitHub Master. My html file contains a leaflet map (leaflet package) which has some interactive features - i.e. you can click on a an area of the map and a popup appears. If I remove the map from the html doc it encrypts fine. Any workarounds available?

Thanks

R 4.1.0 stack overflow

Hi,

Thank you for your package.

I just tried it and I got an error:

R version 4.1.0 (2021-05-18) -- "Camp Pontanezen"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[R.app GUI 1.76 (7976) x86_64-apple-darwin17.0]

> library(encryptedRmd)
> encrypt_html_file(
+   path = "/Users/xxx/Library/Mobile Documents/com~apple~CloudDocs/xxx/xxx/xxx/RMD/DDD.html",
+   output_path = paste0(path, ".enc.html"),
+   key = sodium::random(32L),
+   message_key = TRUE,
+   write_key_file = TRUE,
+   output_template_path = system.file("html-template.html", package = "encryptedRmd"))

Error: segfault from C stack overflow

Any clues if it is related to the new R 4.1.0 version? I am using a Mac mini Intel, 11.3.1 macOS. The file to be encrypted is about 10 MB.

Best, RN.

Release encryptedRmd 0.2.1

Prepare for release:

  • devtools::build_readme()
  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Polish NEWS

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • usethis::use_github_release()
  • usethis::use_dev_version()

Plotly and Plots

Loving the simplicity of this! However, it is not rendering Plotly interactive graphs, which I assume has to do with some way it renders javascript. Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.