mirror of
https://github.com/fergalmoran/podnoms.git
synced 2025-12-24 18:28:34 +00:00
25 lines
737 B
C#
25 lines
737 B
C#
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace PodNoms.Api.Utils.Crypt
|
|
{
|
|
public class MD5Generator
|
|
{
|
|
|
|
public static string CalculateMD5Hash(string input)
|
|
{
|
|
// step 1, calculate MD5 hash from input
|
|
MD5 md5 = System.Security.Cryptography.MD5.Create();
|
|
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
|
|
byte[] hash = md5.ComputeHash(inputBytes);
|
|
|
|
// step 2, convert byte array to hex string
|
|
StringBuilder sb = new StringBuilder();
|
|
for (int i = 0; i < hash.Length; i++)
|
|
{
|
|
sb.Append(hash[i].ToString("X2"));
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
} |