SensitiveDataObfuscator { public static String parseStrToSHA256(String str){ String reStr = ""; try { MessageDigest sha = MessageDigest.getInstance("SHA-256"); byte[] bytes = sha.digest(str.getBytes()); reStr = ByteArrayUtils.byteArrayToHexString(bytes); } catch (NoSuchAlgorithmException e) { logger.warn("Hash sensitive data failed: " + e.getMessage()); } return reStr; }  static List<String> getSensitiveDataFromFile(); static String hashSensitiveDataHierarchically(String key, String value, List<String> expandedSensitiveData); static String hashSensitiveData(String key, String value, List<String> expandedSensitiveData); static String parseStrToSHA256(String str);  }
@Test(groups = { "SensitiveDataObfuscatorTest" }) public void testParseStrToSHA256() { String mask = SensitiveDataObfuscator.parseStrToSHA256("255.255.255.0"); assertEquals(mask, "F9E2C70401F315FEEBFC5B2A2B7493C10578E8E5CC3D7C7354FCF5F34FEC0DB5"); String ip = SensitiveDataObfuscator.parseStrToSHA256("192.168.0.1"); assertEquals(ip, "37D7A80604871E579850A658C7ADD2AE7557D0C6ABCC9B31ECDDC4424207EBA3"); }