[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]
|
|
Problem DescriptionA program is required to somehow overwrite or modify email addresses in a text file to make them unidentifiable. Background & TechniquesI 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. Programmer's Notes:Designing the inputs was a problem for a couple of reasons. Typically word delimiters do not replica watch 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 (by <a href="http://www.testsforge.com/expert/rhian_hanson.html" style="text-decoration: none; color: #000066">rhian hanson</a>). 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. Running/Exploring the Program
Suggestions for Further Explorations
|
[Feedback] [Newsletters (subscribe/view)] [About me]Copyright © 2000-2018, Gary Darby All rights reserved. |