-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
100 lines (73 loc) · 2.73 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# msoc
<!-- badges: start -->
[![R-CMD-check](https://github.com/JanMarvin/msoc/workflows/R-CMD-check/badge.svg)](https://github.com/JanMarvin/msoc/actions)
[![r-universe](https://janmarvin.r-universe.dev/badges/msoc)](https://janmarvin.r-universe.dev/msoc)
<!-- badges: end -->
This R package provides the cryptographic library [msoc](https://github.com/herumi/msoffice) and allows encrypting and decrypting office open xml files with R.
## Installation
You can install the development version of `msoc` from
[GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("JanMarvin/msoc")
```
Or from [r-universe](https://r-universe.dev/) with:
``` r
# Enable repository from janmarvin
options(repos = c(
janmarvin = 'https://janmarvin.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))
# Download and install msoc in R
install.packages('msoc')
```
## Introduction
A word of warning. I have no background in cryptography and I am somewhat unable
to maintain the bundled msoc library. Assume that I only made it work and if it
ever breaks, you are on your own. Due to these reasons the package will never
be released to CRAN either.
Before you encrypt a file, you should memorize the password. If you forget the
password, there is no way to recover the contents of the file.
```{r}
library(msoc)
file <- system.file("extdata", "Untitled1.xlsx", package = "msoc")
# out is an encrypted file and you will
# be unable to open it without the password
out <- encrypt(file, pass = "msoc")
# out is an decrypted file and readable
# without the password
out <- decrypt(out, pass = "msoc")
```
## An example with [`openxlsx2`](https://github.com/JanMarvin/openxlsx2)
```{r}
library(openxlsx2)
library(msoc)
xlsx <- temp_xlsx()
# let us write some worksheet
wb_workbook()$add_worksheet()$add_data(x = mtcars)$save(xlsx)
# now we can encrypt it
encrypt(xlsx, xlsx, pass = "msoc")
# the file is encrypted, we can not read it
try(wb <- wb_load(xlsx))
# we have to decrypt it first
decrypt(xlsx, xlsx, pass = "msoc")
# now we can load it again
wb_load(xlsx)$to_df() %>% head()
```
## License
This package is licensed under the BSD 3-Clause license and is based on
[`msoffice`](https://github.com/herumi/msoffice) (by Cybozu Labs, Inc;
COPYRIGHT 2007-2015 and Shigeo Mitsunari;COPYRIGHT 2015-2023) and [`cybozulib`](https://github.com/herumi/cybozulib) (by Cybozu Labs, Inc;
COPYRIGHT 2007-2012 and Shigeo Mitsunari; COPYRIGHT 2012-2023). Both release
under the BSD 3-Clause License.