# required packages
library(tidyverse)
library(digest)
library(cleanR)
library(DT)
# Function to generate random phone numbers
<- function(n) {
generate_phone_number <- replicate(n, paste0("0", sample(0:5, 5, replace = TRUE), collapse = ""))
phone_numbers return(as.vector(phone_numbers))
}
# Sample data
<- 10 # number of rows in the data frame
n <- paste("List", 1:n)
list_name <- paste("Admin1_", sample(1:100, n, replace = TRUE))
admin1 <- paste("Admin2_", sample(1:100, n, replace = TRUE))
admin2 <- paste("Person_", sample(LETTERS, n, replace = TRUE))
person <- generate_phone_number(n)
PhoneNumber <- stringi::stri_rand_strings(n, 10)
uuid <- paste("List", 1:n)
name
# Create the data frame
<- data.frame(list_name, admin1, admin2, person, PhoneNumber, uuid, name) data
Hash PhoneNumbers
In this example we’ll ecrept or hash phonenumbers so we can avoid exposing such personal identiable data during remote data collection. often in WFP opperations, its common to have benefiairy contact information used for monitoring or verifications surveys. during this time it will be good practice to hash phonenumers in advance and prepare itemset file that you can upload with your MoDa tool. we’ll use the hash_phonenumbers() function to acheive this.
Step 1: Prepare dumpy data
Now lets see how the orginal data looks like, and phone numbers will appear as their original form, which is not recomended to share it widely during remote data collection that we can’t gurentee if the information will be discarded after the data collection
datatable(data, list(dom = 't'))
okay, lets now encrepth the phone numbers
<- hash_phonenumbers(data, 'PhoneNumber', 'name', debug = FALSE)
hashed_data
datatable(hashed_data, list(dom = 't'))