Currently, I'm working on a chrome app that utilizes local storage. The backend returns JSON data which I then save locally and encrypt all the items within the JSON. I have multiple sets of JSON with different encryption functions for each set.
I attempted to create a dynamic function that can return a copy of these JSON sets with each item encrypted, but I couldn't get it to work properly. My JSON includes both arrays and objects.
My question is, is it possible to create such a dynamic function? If yes, could someone provide me with a working sample?
Just so you know, I'm using angularJS and here is the code snippet I am currently working with:
// This function returns a copy of JSON with encrypted values.
fac.encryptData = function(param) {
// Encryption logic goes here
};
In essence, I have separate functions for encrypting different JSON structures, and I want to consolidate them into a single dynamic function to handle encryption for various types of JSON data.