Skip to content

Instantly share code, notes, and snippets.

@Thisura98
Created June 9, 2020 18:03
Show Gist options
  • Save Thisura98/6de20cdee4e1288b869d14be39be3175 to your computer and use it in GitHub Desktop.
Save Thisura98/6de20cdee4e1288b869d14be39be3175 to your computer and use it in GitHub Desktop.
Describes a method to generate MD5 hashes in C#
using System.Security.Cryptography;
public class PaymentPayHereController : BasePaymentController{
/**
MD5 Hashes the input string.
Return value contains only lowercase alphabeticals and numbers.
*/
private string GenerateHash(string input)
{
MD5 provider = new MD5CryptoServiceProvider();
Byte[] inputBytes = ASCIIEncoding.Default.GetBytes(input);
Byte[] hashBytes = provider.ComputeHash(inputBytes);
return BitConverter.ToString(hashBytes).Replace("-", "").ToLower();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment