MD5 Hashing an Email List for LiveIntent with an ASPNet Core Console Application

MD5 Hashing an Email List for LiveIntent with an ASPNet Core Console Application

·

3 min read

I started consulting with a company and told the CTO that I would help him fill the gaps because the team was becoming overextended in several different areas from Dev Ops, Azure, Infrastructure, Internal Projects and Development (adding features/etc) to the core system. Sometimes I feel like the internet janitor which by all means isn't as bad as it sounds, it just means I have experience working in every nook and cranny over my 20+ year career.

I enjoy getting into the nitty-gritty and one recent request I had from the marketing department was to MD5 hash an email list to be imported into Live Intent. I didn't have a lot of time to sit down, analyze all of the details, I was just told that Live Intent needed an MD5 hashed list of emails to be imported. For this blog post I looked up a little more information on what Live Intent is doing and they do support other encryption algorithms so I wonder why they even accept MD5 hashing but let's not digress.

It took me less than 30 minutes to get something out for them to use and my time was better spent on this than setting up meetings to argue about hashing vs encryption (for a third-party system no less). My main goal was to give marketing a tool they could use in the short term with the least amount of effort so that they didn't need to request help from I.T. because nobody likes waiting for us to get to their requests. In the future we can build something more robust and automated.

The process was simple:

  • Model the input file which in my case is one column with an email.
  • Output is just a column with the email hashed
  • Hard code all the paths and later if we need to make it more dynamic we can invest more time in it
  • Add a reference to ServiceStack.Text for its String Utilities and FromCsv extension method which rocks and does 90% of the heavy lifting

Let me caveat a few things for you about this code if you need to do something similar:

  • This example has no error checking but you'll definitely want to add your own
  • You should be checking paths to ensure they exist/etc.
  • My real-world example accepts command line arguments just to make it easier for the user. I wanted to provide you with a concise example and didn't add these here.
  • The core requirement to MD5 has an email list is pretty trivial and hopefully if you have to do the same you can take this and run with it.
  • I didn't require this for now but if you need more heavy-duty CSV processing I recommend CSVHelper.
  • With projects like this, my preference is to iterate over them so first version is to be kept as simple as possible. I have other priorities (adding features to the core web application) so the goal is to help out but not impact those priorities.

Here you go, problem solved in less than 20 lines of code: