inotify/Inotify/Common/Extensions.cs
2021-03-24 23:09:35 +08:00

27 lines
761 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Inotify.Common
{
public static class Extensions
{
/// <summary>
/// MD5加密字符串32位大写
/// </summary>
/// <param name="source">源字符串</param>
/// <returns>加密后的字符串</returns>
public static string ToMd5(this string source)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] bytes = Encoding.UTF8.GetBytes(source);
string result = BitConverter.ToString(md5.ComputeHash(bytes));
return result.Replace("-", "");
}
}
}