Solution: Data Sanitization Pipeline

Review the implementation of a static extension method for string manipulation.

Solution: Data Sanitization Pipeline

Review the implementation of a static extension method for string manipulation.
C# 14.0
namespace Finance.Utilities;
public static class StringExtensions
{
public static string MaskSensitiveData(this string input)
{
if (string.IsNullOrEmpty(input) || input.Length <= 4)
{
return input;
}
string result = "";
int maskLength = input.Length - 4;
// Manually build the string using basic loops and concatenation
for (int i = 0; i < input.Length; i++)
{
if (i < maskLength)
{
result += "*";
}
else
{
result += input[i];
}
}
return result;
}
}