2020-04-19 06:18:28 -07:00
|
|
|
#nullable enable
|
|
|
|
|
2019-01-13 13:01:16 -07:00
|
|
|
using System;
|
2019-12-10 16:13:57 -07:00
|
|
|
using System.Security.Cryptography;
|
2019-03-25 14:25:32 -07:00
|
|
|
using System.Text;
|
2018-12-27 16:27:57 -07:00
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
namespace MediaBrowser.Common.Extensions
|
|
|
|
{
|
|
|
|
/// <summary>
|
2019-12-10 16:13:57 -07:00
|
|
|
/// Class BaseExtensions.
|
2018-12-27 16:27:57 -07:00
|
|
|
/// </summary>
|
|
|
|
public static class BaseExtensions
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Strips the HTML.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="htmlString">The HTML string.</param>
|
2019-09-20 03:42:08 -07:00
|
|
|
/// <returns><see cref="string" />.</returns>
|
2018-12-27 16:27:57 -07:00
|
|
|
public static string StripHtml(this string htmlString)
|
|
|
|
{
|
|
|
|
// http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net
|
2019-09-20 03:42:08 -07:00
|
|
|
const string Pattern = @"<(.|\n)*?>";
|
2018-12-27 16:27:57 -07:00
|
|
|
|
2019-09-20 03:42:08 -07:00
|
|
|
return Regex.Replace(htmlString, Pattern, string.Empty).Trim();
|
2018-12-27 16:27:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2019-09-20 03:42:08 -07:00
|
|
|
/// Gets the Md5.
|
2018-12-27 16:27:57 -07:00
|
|
|
/// </summary>
|
2019-09-20 03:42:08 -07:00
|
|
|
/// <param name="str">The string.</param>
|
|
|
|
/// <returns><see cref="Guid" />.</returns>
|
2018-12-27 16:27:57 -07:00
|
|
|
public static Guid GetMD5(this string str)
|
|
|
|
{
|
2019-12-10 16:13:57 -07:00
|
|
|
#pragma warning disable CA5351
|
2019-03-25 14:25:32 -07:00
|
|
|
using (var provider = MD5.Create())
|
|
|
|
{
|
|
|
|
return new Guid(provider.ComputeHash(Encoding.Unicode.GetBytes(str)));
|
|
|
|
}
|
2019-12-10 16:13:57 -07:00
|
|
|
|
|
|
|
#pragma warning restore CA5351
|
2018-12-27 16:27:57 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|