-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method to encrypt a single field #5
Comments
You could store them in a list column like this: # Example data
key <- hash(charToRaw("This is a secret passphrase"))
mydata <- iris
mydata$cipher <- lapply(mydata$Species, function(x) {
sodium::data_encrypt(serialize(as.character(x), NULL), key = key)
})
vapply(mydata$cipher, function(cipher){
unserialize(sodium::data_decrypt(cipher, key = key))
}, "character") |
Alternatively you could convert each raw value to a string using e.g. |
Thanks Jeroen,
I will have to ponder further as the resulting field needs to be
sorted-able for dplyr::group_by() and dplyr::arrange(), and available as an
SQL merge key. Thanks for the ideas.
…On Tue, 6 Jun 2017 at 13:08 Jeroen Ooms ***@***.***> wrote:
Alternatively you could convert each raw value to a string using e.g.
sodium::bin2hex or jsonlite::base64_enc.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#5 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AIPm4fPqYS6mjrMggNmqpEA4H577LTw8ks5sBbGsgaJpZM4Nx0f1>
.
|
In that case you probably want to map the raw vectors to strings with |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Often one needs to encrypt one or more fields from a tibble/dataframe/data table with a function which returns the cypher to the appropriate row of the table, and then one would drop the plaintext. eg.
iris_confidential <- iris %?>% mutate(
encrypted_species = magic_function(species, ...)
) %>% select (-species)
I have been unable to coax sodium into doing a single-column encryption, or more precisely when I do I get an object back that has more observations than the data frame has rows. One can't then push the resulting vector back into the data_frame. If there a way to coax magic_function() out of sodium?
See:
You can't stuff either cipher or msg back into the data frame because the row-numbers don't align.
The text was updated successfully, but these errors were encountered: