Obfuscator Framework

Last updated: Nov 23th, 2019

General

Obfuscator Framework - mask the sensitive fields using MD5 , SHA258 , Fixed Mask and Matched Mask.

Java

Obfuscator framework provides simplified configuration to obfuscate the sensitive field while logging the data for java projects

Repository
 maven { url "https://dl.bintray.com/m2/release/"}
Dependency- Gradle
compile ("io.devxchange:obfuscator:0.0.1")
MD5
Usage
============
//Fields to obfuscated
Set items = new HashSet<>();
items.add("name");
items.add("salary");
items.add("age");

Map> obfuscatorMap= new HashMap<>();
obfuscatorMap.put("md5", items);
// obfuscate json object
String response = Obfuscator.obfuscateJsonString(simpleJson,obfuscatorMap);
// obfuscate XML object
String response = Obfuscator.obfuscateXmlString(simpleXML,obfuscatorMap);

Input
=====
{"id":1,"name":"karthik","age":29,"salary":115000}

Output - MD5 Encrypted Response
=================================
{
  "id": 1,
  "name": "02adcec2263d2127269fcd769c33f029",
  "age": "6ea9ab1baa0efb9e19094440c317e21b",
  "salary": "560c237ab6f39688c4c45dc23e0d494e"
}
SHA256
Usage
============
//Fields to obfuscated
Set items = new HashSet<>();
items.add("name");
items.add("salary");
items.add("age");

Map> obfuscatorMap= new HashMap<>();
obfuscatorMap.put("sha256", items);
// obfuscate json object
String response = Obfuscator.obfuscateJsonString(simpleJson,obfuscatorMap);
// obfuscate XML object
String response = Obfuscator.obfuscateXmlString(simpleXML,obfuscatorMap);

Input
=====
{"id":1,"name":"karthik","age":29,"salary":115000}

Output - SHA256 Encrypted Response
=================================
{
  "id": 1,
  "name": "63b7cc6dd0c192e8f73170629701879816156027e44bbee145a7a8456a9a3517",
  "age": "35135aaa6cc23891b40cb3f378c53a17a1127210ce60e125ccf03efcfdaec458",
  "salary": "f190a3d0c04e5b2b3f4ee16d2df26597720b8d1c09179d2a0dad7e4605776875"
}
FixedMask
Usage
============
//Fields to obfuscated
Set items = new HashSet<>();
items.add("name");
items.add("salary");
items.add("age");

Map> obfuscatorMap= new HashMap<>();
obfuscatorMap.put("fixedMask", items);
// obfuscate json object
String response = Obfuscator.obfuscateJsonString(simpleJson,obfuscatorMap);
// obfuscate XML object
String response = Obfuscator.obfuscateXmlString(simpleXML,obfuscatorMap);

Input
=====
{"id":1,"name":"karthik","age":29,"salary":115000}

Output - Fixed Mask Response
=======================================
{
  "id": 1,
  "name": "********",
  "age": "********",
  "salary": "********"
}
MatchedMask
Usage
============
//Fields to obfuscated
Set items = new HashSet<>();
items.add("name");
items.add("salary");
items.add("age");

Map> obfuscatorMap= new HashMap<>();
obfuscatorMap.put("matchedMask", items);
// obfuscate json object
String response = Obfuscator.obfuscateJsonString(simpleJson,obfuscatorMap);
// obfuscate XML object
String response = Obfuscator.obfuscateXmlString(simpleXML,obfuscatorMap);

Input
=====
{"id":1,"name":"karthik","age":29,"salary":115000}

Output - Matched Mask Response
=================================
{
  "id": 1,
  "name": "*******",
  "age": "**",
  "salary": "******"
}