Email list Hashing on a Windows laptop

Cintirich

Limp Gawd
Joined
Oct 9, 2006
Messages
244
Hi all,

I recently had a sFTP site set up at work so that I can directly send sensitive files to our vendors, including email opt-out and suppression lists. We are currently using a 3rd party company to do this and it's very expensive.

Industry best practice dictates that we should use a one-way hash (MD3 or MD5) to protect the email addresses from being compromised.

Apparently this is very easy to do using a Linux box, but I run on a Windows 7 laptop and we would like to keep all the functions of this site "in house", meaning me.

When I asked one of our security guys about how to do this, this is what he said:

You would have to find a program to do it or write a script. It’s easy on Linux:

deckard:~> cat email.txt
[email protected]
[email protected]
[email protected]
[email protected]
deckard:~> foreach i ( `cat email.txt` )
foreach? echo $i | md5sum >> output.txt
foreach? end
deckard:~> cat output.txt
e3b1039de8a60d34ec26ac399d331d6c -
779a1b04894b5baf192dd60328bc7a3c -
ce5a117cf281b585e51c148d0590ba72 -
844ab0f2f8ce63760d92b75722be5b87 -

Not sure how to do it on Windows.

Can anyone give any pointers on where to start? Can I run a linux VM, can I use a Windows command line function, etc?

Any help would be appreciated. Thanks!

Rich
 
The script is actually incorrect as `echo` will append a newline to the end of output, thus you'd be generating a hash for "[email protected]\n" instead of "[email protected]". If that is what is intended then nevermind.

To answer your question, I imagine you could do this in Powershell, but as I'm not an expert with powershell, you can try the below with Cygwin.

Here is a simple bash script. (This hashes just the email, no newline characters).

emailhash.sh
Code:
#!/bin/bash

EMAIL_FILE=$1
while read email
do
        echo -n "$email" | md5sum
done < $EMAIL_FILE

Invoke as such
emailhash.sh email.txt > email_hashes.txt

You can QA by trying a couple emails from the list and doing, and seeing if the output matches the what the script generates.

Code:
echo -n "email" | md5sum

where "email" is replaced with a real email.
 
Last edited:
Back
Top