hideData method

String hideData({
  1. required String data,
  2. required List<HideRegExp> hideRegExps,
  3. bool ignoreError = false,
})

Implementation

String hideData({
  required String data,
  required List<HideRegExp> hideRegExps,
  bool ignoreError = false,
}) {
  for (var i = 0; i < hideRegExps.length; i++) {
    try {
      HideRegExp hideRegExp = hideRegExps[i];
      if (hideRegExp.regExp.hashData(data)) {
        if (hideRegExp.hideDataType == HideDataType.replace) {
          data = data.replaceAll(hideRegExp.regExp, hideRegExp.replace);
        }
        if (hideRegExp.hideDataType == HideDataType.obfuscate) {
          data = obfocustData(
            mystring: data,
            start: hideRegExp.startIndexObfuscate,
            end: hideRegExp.endIndexObfuscate,
          );
        }
      }
    } catch (e) {
      if (ignoreError) {
        continue;
      } else {
        rethrow;
      }
    }
  }
  return data;
}