Masking sensitive data using Dataweave in Mulesoft

In this article, we will discuss an example of how to mask sensitive data using Dataweave in Mulesoft. Dataweave has an operator called mask which can achieve data masking. In order to use mask function we have to import Values (dw::util::Values).

Input:

{
"employee": {
"id": "101",
"firstName": "John",
"lastName": "Grisham",
"designation": "Engineer",
"salary": 20000,
"gender": "M",
"email": "101@a.com",
"phone": "1234567890"
}
}

Output:

{
"employee": {
"id": "101",
"firstName": "JOHN",
"lastName": "G***",
"designation": "Engineer",
"salary": "$20,000.00",
"gender": "M",
"email": "***@a.com",
"phone": "(###)-###-7890"
}
}

Below image shows the dataweave code and output.

Below image shows the same logic for array input.

Here is the dataweave code.

--

--