# 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("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, person, PhoneNumber, uuid, name) data
Hash PhoneNumbers
In this example, we’ll encrypt or hash phone numbers to avoid exposing personal identifiable data during remote data collection. Often in WFP operations, it’s common to use beneficiary contact information for monitoring or verification purposes. During this time, it is good practice to hash phone numbers in advance and prepare an itemset file that you can upload with your MoDa tool. We’ll use the hash_phonenumbers() function to achieve 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'))
Step 2: Generate Hashcode
okay, lets now encrepth the phone numbers and generate the hashcode.
<- hash_phonenumbers(data, 'PhoneNumber', 'name', debug = FALSE)
hashed_data
datatable(hashed_data, list(dom = 't'))
Step 3: Include output in your XLSForm
Now you can export the encryped dataframe and include it in your XLSForm choices sheet. personally I don’t prefer to include such data as external itemset. so that is why its better to include it in the choices sheet.