EDI File Scrubber
Sometimes there is a need to mask sensitive data. IDs, social security numbers, names and addresses are just a few items that may require this. EDIFileScrubber allows developers to mask data without having to understand the X12 standard.
For example, let’s take a simple ISA segment
ISA*00* *00* *ZZ*ASHTB *ZZ*01017 *040315*1005*U*00401*004075123*0*P*:~
After processing the EDI file any element could be masked using the EDI File Scrubber. For example:
ISA*QQ*QQQQQQQQQQ*QQ*QQQQQQQQQQ*ZZ*ASHTB *ZZ*01017 *040315*1005*U*00401*004075123*0*P*:~
As shown below we have just masked element 1,2,3 and 4 by replacing their values with the letter ‘Q’. Notice that the lengths of the elements remain the same. Developers can configure any element or composite element value to be masked.
Scrubbing from a File or In-Memory String
EDIFileScrubber can scrub files from the file system using the EDIFile property or from a string of EDI data using the EDIDataString property.
Auto Detection of Delimiters
EDIFileScrubber has a Delimiter property that can be set if these delimiters are known beforehand. It also has a property called AutoDetectDelimiters. By enabling this property EDIFileScrubber detects the special delimiter characters while scrubbing is being performed.
Accessing Scrubbed Data
Because EDIFileScrubber does not use any rules file, there is no validation on the EDI data. More importantly there is no proper hierarchy data conforming to the EDI implementation guides as you would find in the EDIValidator component. There is only one main loop containing all the scrubbed segments and elements that exist in the EDI file. This gives developers the flexibility to consume this data however they please.
// Create a new instance of EDIFileScrubber
EDIFileScrubber scrubber = new EDIFileScrubber
scrubber.AutoDetectDelimiters = true;
// Set the type of EDI file that you are about the scrub
scrubber.EDIFileType = FileType.X12; //Or FileType.EDIFACT
// Set the source of EDI data, whether you are scrubbing from an in-memory string or a file. If you are scrubbing from a string then set the EDIDataString property to the EDI data
scrubber.EDISource = EDISource.File // Or EDISource.DataString
// Set the EDI file path to scrub
scrubber.EDIFile = "C:\\EDIFile.txt
// Set the scrubbing rule (s)
// Set element 0,1,2,3 of the ISA segment to be replaced by the character 'Q'
ScrubRule rule = new ScrubRule();
rule.SegmentName = "ISA";
rule.ReplaceCharacter = 'Q';
// Set composite element 0 element 0 of the SVC segment to be replaced by the character 'W'
ScrubRule rule2 = new ScrubRule();
rule2.SegmentName = "SVC";
rule2.ReplaceCharacter = 'W';
// scrub the data
EDILightWeightDocument doc = scrubber.Scrub();