0

I have a list of emails in a txt file that a vendor is requesting to be MD5Hash encrypted. From my understanding MD5Hash isn't an encryption so I'm unsure how to do this.

Is there a terminal command to take a txt file and MD5hash every single email in the file so it is "encrypted"?

The only terminal command I know regarding MD5hash and the result when I MD5hash the file is below:

MD5 -r /Users/Me/Desktop/test_file.txt

Result is:

0240da8148f06ae774de0831eda20eee /Users/Me/Desktop/test_file.txt

Anyone know of a method to (I guess) MD5hash every single email in the file? There are 20k emails, so doing each one individually isn't an option. Or am I misunderstanding how MD5Hash should be used for an email list? And FYI I'm using Terminal on a Mac.

Thanks!

jgrannis
  • 321
  • 1
  • 3
  • 13
  • 1
    You're right that MD5 is not an encryption algorithm. It's a non-keyed one-way hash function. Digests that MD5 produces cannot be decrypted. So, I suggest you first make sure that everyone involved understands what the requirements are. Perhaps the hashes should only be used as a checksum to detect non-malicious data-mutation (e.g. in transit). – Artjom B. Apr 09 '15 at 20:47

1 Answers1

1

I guess they don't want to transport plain text emails. Later they will compare hashes of their emails to your file.

For examle emails.txt:

a@a.com
b@b.com
c@c.com
d@d.com

Command that writes MD5-s of each e-mail to new file:

cat emails.txt | while read line; do echo -n $line|md5; done >> emailsMd5.txt

If you have a file containing comma separated emails:

cat emailsCommaSep.txt | perl -pe s/,/\\n/g | while read line; do echo -n $line|md5 done >> emailsMd5.txt

Sources:

Community
  • 1
  • 1
tiblu
  • 2,959
  • 1
  • 22
  • 22
  • For some reason when I try to use your first suggestion (cat emails.txt | ......) the file comes up blank. Any idea why? – jgrannis Apr 09 '15 at 21:50
  • Well, I'll be honest - I did this on Ubuntu, so there may be some differences with OSX. Start off by splitting the task from pipes, and see the output. It also gives you an idea what each command does. So, try: ``cat emails.txt`` Should output the file contents. Then: ``cat emails.txt | while read line; do echo -n $line|md5; done`` Which should output md5-s of each line. I am suspicious that ``| cut -d ' ' -f 1`` is not needed on OSX. – tiblu Apr 10 '15 at 07:06
  • @jgrannis Fixed the answer. The OSX md5 and Ubuntu md5sum output differs a bit, so ``| cut -d ' ' -f 1`` is not needed. – tiblu Apr 10 '15 at 07:57
  • Great, I did your instructions step by step to check everything in terminal and found that the source file wasn't formatted properly. Net net, I was finally able to get each email hashed and outputted into one large file. Thanks for your help! – jgrannis Apr 13 '15 at 07:36