View Full Version : Terminal: Convert file contents (emails) to MD5
jobetter23
Nov 17, 2010, 02:40 PM
Hey guys, anybody know, via terminal, how to convert a file with many lines of e-mails into an md5 file and export it ito .txt file- if possible , not to delete the e-mails.
ex :
jojo@aol.com into
Jojo@aol.com, 60b4498f429ea861dhja7807ae69ec4a
any help will be great! :rolleyes:
mfram
Nov 17, 2010, 05:56 PM
What's the goal of what you are trying to accomplish? MD5 is a hashing algorithm. It's designed to show that the contents of two files are the same. So if you hash a file, it would have nothing do with deleting it. MD5 is not encryption.
balamw
Nov 17, 2010, 07:56 PM
$ md5 -s jojo@aol.com
MD5 ("jojo@aol.com") = 8f6267dd59127998be428284e7ebee1e
Wrap that in a for loop and you're most of the way to what I think you want.
B
Zazoh
Nov 17, 2010, 10:30 PM
You will need to loop and find a pattern. For example XXXXXXX@xxxxx.xxxxx where the xxxxs can be anything. I recently did this in JavaScript using the match method. Not sure it's equivalent in c or other scripting Lang.
jobetter23
Nov 18, 2010, 01:53 PM
What's the goal of what you are trying to accomplish? MD5 is a hashing algorithm. It's designed to show that the contents of two files are the same. So if you hash a file, it would have nothing do with deleting it. MD5 is not encryption.
This is my goal: somebody sends me a file of md5 encrypted e-mails. So i need to turn my own list of normal e-mails into MD5 so i can compare it with that md5 list that they send me.
So i want to input my entire list of regular e-mails (thousands of lines) and input it into terminal and have it return a new file of md5 names.
If there is an easier way to do this let me know
Thanks so much!!
cqexbesd
Nov 19, 2010, 01:57 PM
Hey guys, anybody know, via terminal, how to convert a file with many lines of e-mails into an md5 file and export it ito .txt file- if possible , not to delete the e-mails.
ex :
jojo@aol.com into
Jojo@aol.com, 60b4498f429ea861dhja7807ae69ec4a
any help will be great! :rolleyes:
perl -MDigest::MD5 -n -E 'chomp($_); say(join(", ", $_, Digest::MD5::md5_hex($_)))'
Feed it the data on stdin, get the output on stdout.
Andrew
ulbador
Nov 19, 2010, 02:40 PM
perl -MDigest::MD5 -n -E 'chomp($_); say(join(", ", $_, Digest::MD5::md5_hex($_)))'
Feed it the data on stdin, get the output on stdout.
Andrew
Ahh, this is where Perl truly shines...
jobetter23
Nov 20, 2010, 09:25 PM
perl -MDigest::MD5 -n -E 'chomp($_); say(join(", ", $_, Digest::MD5::md5_hex($_)))'
Feed it the data on stdin, get the output on stdout.
Andrew
Sorry just a little new to this - where exactly am i supposed to insert the file (and the output), if u can tell me where exactly in the code.
Thanks!!
subsonix
Nov 21, 2010, 07:12 AM
There are also alternative ways to do this in bash, (to expand on what balamw was suggesting).
while read line; do md5 -s "$line" ; done < emails.txt
This will take a text file with emails and dump the md5 checksums to stdout. You can also redirect the output to a new file if you want to.
jobetter23
Nov 21, 2010, 08:12 AM
Thanks ! Both work great!! magic!
jobetter23
Nov 21, 2010, 01:23 PM
perl -MDigest::MD5 -n -E 'chomp($_); say(join(", ", $_, Digest::MD5::md5_hex($_)))'
Feed it the data on stdin, get the output on stdout.
Andrew
Is there a way to add a line break in this code so that he first line of the stdout is a blank line?
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.