This function uses the scrypt algorithm from libsodium to anonymise data,
based on user-indicated data fields. Data fields are concatenated first,
then each entry is hashed. The function can either return a full detailed
output, or short labels ready to use for 'anonymised data'.
Before concatenation (using "_" as a separator) to form labels,
inputs are modified using
Data fields to be hashed.
The number of characters retained in the hash.
A logical indicating if the a full output should be returned as a
An optional object that can be coerced to a character
to be used to 'salt' the hashing algorithm (see details).
salt should be used for salting the algorithm, i.e. adding
an extra input to the input fields (the 'salt') to change the resulting hash
and prevent identification of individuals via pre-computed hash
It is highly recommend to choose a secret, random salt in order make it harder for an attacker to decode the hash.
clean_labels, used to clean labels prior to hashing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
first_name <- c("Jane", "Joe", "Raoul") last_name <- c("Doe", "Smith", "Dupont") age <- c(25, 69, 36) hash_names(first_name, last_name, age) hash_names(first_name, last_name, age, size = 8, full = FALSE) ## salting the hashing (more secure!) hash_names(first_name, last_name) # unsalted - less secure hash_names(first_name, last_name, salt = 123) # salted with an integer hash_names(first_name, last_name, salt = "foobar") # salted with an character
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.