MailChimp.Api.Net icon indicating copy to clipboard operation
MailChimp.Api.Net copied to clipboard

Add MD5Hash to BaseOperation

Open enkodellc opened this issue 8 years ago • 2 comments

I think it would benefit users to include a method to do the MD5hash within the BaseOperation Class. Then update each method that requires the MD5 hash parameters to be just the email or standard string. From what I can see there is no need for this to be a hashed value in this API wrapper. This change should simplify the methods where the MD5 is utilized reducing the amount of extra coding for those who implement this API. I spent about 30 minutes testing the DeleteMemberAsync and it was failing as I was using an incorrect MD5Hash algorithm.

If you agree I will create a PR for these changes.

enkodellc avatar Jul 12 '16 11:07 enkodellc

Lets hold this idea for now. We will revisit this conversation later on.

shahriarhossain avatar Jul 13 '16 07:07 shahriarhossain

Sounds good. I am thinking it might be good for next major release. I have a few other smaller items might bring to the table but most I am cleaning up as I review and add features to existing items.

Here is the code so if someone does search for the string to MD5 hash they can find it

  public static string GetMd5HashString(string yourString )
  {
     return string.Join("", MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(yourString)).Select(s => s.ToString("x2")));
  }

enkodellc avatar Jul 13 '16 22:07 enkodellc