How to do Encode and encrypt the multiple number?

I have JSON data as below:

{
    "Body": {
        "AccNum": [
            "000405010255",
            "000405010310",
            "000405009777",
            "000401109537",
            "000401113460",
            "000401116861",
            "001805015288",
            "628801537715",
            "000319000184",
            "000401193586",
            "000405111139",
            "000405501186",
            "000760004994",
            "000805015689",
            "000813001320",
            "001105024982",
            "001801080623",
            "001810042371",
            "001825075268",
            "004214109637",
            "004214109638",
            "010310000278",
            "032501004151",
            "044205008102",
            "105701000275",
            "630010075140"
        ]
    }
}

Now i have to fetch the number one by one and replace the first 8 digits of the number with "X" like ex: "XXXXXXXX0255" and then encode the number and after encrypt the number. How can i do this part for all numbers? Like ex. first, it'll fetch the first number then it'll hide the first 8 digits of that number after it will encode the number and encrypt the number after it will fetch the second number it will process the same. for all numbers, i have to process like this.

0 1 83
1 REPLY 1

You have options for masking data in Apigee....

  1. you can do it with an external service, something like the "Data Loss Protection" service at Google Cloud. You would be able to call out to such a service with the ServiceCallout policy included in Apigee.
  2. you can do it "manually", with a JavaScript policy that simply walks through the data and applies the mask you desire.

One way or the other, your data will be masked so that each of the resulting fields look like "XXXXXXXX0255" .

That's the first step, "masking".

And you then said you'd like to "encode and after encrypt" the data. I'm not clear on this step. Can you explain what you mean by "encode and encrypt"? And ... your request suggests that you'd like to piecewise encode and encrypt each number separately. That's the way I'm reading what you've written. That's atypical. Normally people will encrypt an entire payload - not one number at a time.

Can you explain a little further about what you're aiming to do?