Encrypting Data in ODK-X

I am wondering if there is any encryption I can do to certain column data before its posted to ODK Tables.

I have been trying to use a simple technique through:

  1. Using simple .replace() function of javascript. So once the data clerk has entered the data I am recoding it using the .replace function e.g a 1 can be assigned to be #. I will then use the assign and calculate to replace the actual value with the replacement. So ODK Table will store this last value. However my challenge is when the data clerk once to review the entered data. I need a way to do reverse replacement. I have been trying to show the actual value in a note but I noted that the display.prompt.text column seem not to be taking the JS formula for replace. I have been trying The key entered is {{data.variable_name}}.replace(’*’,‘1’) but its failing.

I would appreciate any suggestions on any proven methods.

Hi @cmuchuchuti

display.prompt.text takes a Handlebars expression. You cannot directly use JS but you can call functions defined in the calculates sheet through the evaluate Handlebars helper.

For example,
If you have a function defined in calculates called maskOne. In display.prompt.text you can use {{evaluate calculates.maskOne}}.

Another option is to use a session variable to store the modified string. This gives you a bit more flexibility when assigning values.

Custom prompt types is another option, which gives you full scripting capabilities.

Handlebars documentation
https://handlebarsjs.com/guide/#custom-helpers

Session variables
https://docs.odk-x.org/xlsx-converter-reference/#model

Custom prompt types
https://docs.odk-x.org/xlsx-converter-using/#customizing-prompts

2 Likes

Thanks @linl33. I will try this and advise.

1 Like