Comments (4)
The encrypt_
functions are neither undocumented nor internal and are part of the package API.
One possible way of using them would be to do:
save_enc_rds <- function(...) {
## The 'rlang' package provides other ways of doing this
envir <- parent.frame()
call <- sys.call()
call[[1L]] <- quote(saveRDS)
## Following your example, with 'key' found in the global
## environment; I'd recommend doing something more robust here
## personally.
cyphr::encrypt_(call, key, envir = envir)
}
then use as:
key <- cyphr::key_sodium(sodium::keygen())
obj <- runif(10)
path <- tempfile(fileext = ".rds")
save_enc_rds(obj, path, compress = FALSE, version = 3) # note extra args
cyphr::decrypt(readRDS(path), key)
However, much simpler would be to use cyphr::encrypt_object
directly, unless you really need to pass more arguments into the serialiser.
path <- tempfile(fileext = ".rds")
cyphr::encrypt_object(obj, key, path)
cyphr::decrypt_object(path, key)
from cyphr.
Ah, I see. I was under that false impression due the similarity with Python's _single_leading_underscore
. In that process, I also learned about single_trailing_underscore_
, which is quite a different concept :)
So that looks very useful then, thanks!
from cyphr.
Use the encrypt_
version directly and construct the call yourself (e.g., using rlang's tools or substitute
yourself), or by using the less "helpful" cyphr functions such as encrypt_data
from cyphr.
Thanks - relying on undocumented/internal functions such as encrypt_
is nothing I like to do, unfortunately.
I ended up using
save_enc_rds <- function(object, file) {
cyphr::encrypt(saveRDS(object, file), key)
}
which is enough for my use case. I'll have to add additional arguments as needed, but that API is probably stable enough.
from cyphr.
Related Issues (20)
- Documentation about key finding in ?cyphr::keypair_openssl is not correct
- Proper connections HOT 2
- Ability to install without sodium HOT 4
- encrypt/decrypt could work with keys that are registered as defaults
- data_key should look for .cyphr directory recursively if no default given
- version 1.0.0 HOT 4
- Can I decrypt string if it was encrypt by PHP blowfish? HOT 1
- Signature of data does not match HOT 2
- Update on CRAN to fix check failure
- Customize the directory name ".cyphr" HOT 3
- Fix for R 4.0.0 change in stringsAsFactors behaviour
- Migrate cyphr schema
- Add additional metadata when requesting access
- Move to GHA HOT 1
- Confirm correct terminology in .cyphr/README.md HOT 1
- Is it possible to encrypt `arrow` files using the `cyphr` package? HOT 2
- Memory limit error for `encrypt()` HOT 3
- Allow `id_ed25519.pub` key file to be found as default SSH key HOT 3
- Deterministic encryption HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cyphr.