View source: R/hash-and-salt.R
hash_and_salt_sha_256 | R Documentation |
Uses digest::digest()
to hash as (salted) value, using 'SHA-256'.
If the x
isn't already a character
vector, it's converted to one (even if x
inherits from character).
This approach protects the actual value of x
, while still allowing a downstream user
to determine which cells were derived from the same x
.
For example, suppose a patient's
mrn
of '111' is hashed, and the output is 'abc'.
(To view it's real value, execute OuhscMunge::hash_and_salt_sha_256(111)
.)
When given the value 'abc', is it computational infeasible to determine the input
had been '111' (especially when salted). However, when you see that two visits
have an mrn of 'abc', you can determine the same patient generated both visits.
hash_and_salt_sha_256(
x,
salt = "",
min_characters = 1L,
max_characters = 2048L,
na_if = c("")
)
x |
A vector of values to convert. it should be a |
salt |
A single-element character vector. |
min_characters |
The minimum count of characters that |
max_characters |
The maximum count of characters that |
na_if |
A vector of characters that should produce a has of |
A character vector.
Will Beasley
cryptographic hash function and salts.
x <- letters[1:5]
salt <- "abc123"
hash_and_salt_sha_256(x, salt)
# If an unsalted hash is desired, leave the `salt` parameter blank
hash_and_salt_sha_256(x)
# By default, a zero-length character produces hash of NA.
hash_and_salt_sha_256(c("a", "", "c"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.