Snippets

Dmitry Popov String extensions

Created by Dmitry Popov last modified
namespace System
{
    using System.Security.Cryptography;

    public static class StringExtensions
    {
        private static readonly MD5 Md5HashProvider = MD5.Create();

        public static string GetMD5Hash(this string value)
        {
            var hashBytes = Md5HashProvider.ComputeHash(Text.Encoding.UTF8.GetBytes(value));
            return BitConverter.ToString(hashBytes).Replace("-", string.Empty).ToLowerInvariant();
        }
    }
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.