[Home] [Puzzles & Projects] [Delphi Techniques] [Math Topics] [Library] [Utilities]
A program is required to somehow overwrite or modify email addresses in a text file to make them unidentifiable.
Background & Techniques
I recently needed to send the log file from a newsletter mailing to help diagnose a minor problem. However the log file contained the email addresses of each recipient and sending them in unsecured plain text did not seem like a good idea. This program obfuscates (confuses) email address one of two ways; replacing the name portion with a random word or replacing the entire email address with an "Address removed" phrase. In both cases, email addresses are identified by the embedded @ symbol. As an exercise that might be useful some day, I added an option to obfuscate the word following a given word. For example, changing the word following the word "Password:".
Two sample test files are included in the downloadable zip files below. No worry, the addresses and passwords have already been obfuscated J.
Non-programmers are welcome to read on, but may want to jump to bottom of this page to download the executable program now.
Designing the inputs was a problem for a couple of reasons. Typically word delimiters do not distinguish between the beginning and ending of a word, but I had decided to use "@" as the end of word delimiter to tell me that this was the name portion of an address. The start of word delimiters were the traditional ones such as space, comma, colon semicolon, etc. So we needed start and end delimiters specified separately. Also, allowing the user to specify the delimiters as a string of characters works fine except for the invisible space character. I added a separate check box to specify the "space is a delimiter" condition. For the second mode, replacing the entire address, I needed to recognize words containing an "@" sign as addresses, so a "word contains" option was added to the inputs. Finally for the "Password" option, we need a way to indicate that the word following the recognized word is the one to be obfuscated.
Program logic is simple; a loop until "end-of-file" reads a line from the selected input file, checks for words requiring changes, modifies the line as directed, and writes the line to the output files whether it was modified or not.
Suggestions for Further Explorations
Copyright © 2000-2013, Gary Darby
All rights reserved.