| | | 1 | | using System; |
| | | 2 | | using System.Security.Cryptography; |
| | | 3 | | using System.Text; |
| | | 4 | | using System.Text.RegularExpressions; |
| | | 5 | | |
| | | 6 | | namespace MediaBrowser.Common.Extensions |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Class BaseExtensions. |
| | | 10 | | /// </summary> |
| | | 11 | | public static partial class BaseExtensions |
| | | 12 | | { |
| | | 13 | | // http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net |
| | | 14 | | [GeneratedRegex(@"<(.|\n)*?>")] |
| | | 15 | | private static partial Regex StripHtmlRegex(); |
| | | 16 | | |
| | | 17 | | /// <summary> |
| | | 18 | | /// Strips the HTML. |
| | | 19 | | /// </summary> |
| | | 20 | | /// <param name="htmlString">The HTML string.</param> |
| | | 21 | | /// <returns><see cref="string" />.</returns> |
| | | 22 | | public static string StripHtml(this string htmlString) |
| | 0 | 23 | | => StripHtmlRegex().Replace(htmlString, string.Empty).Trim(); |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets the Md5. |
| | | 27 | | /// </summary> |
| | | 28 | | /// <param name="str">The string.</param> |
| | | 29 | | /// <returns><see cref="Guid" />.</returns> |
| | | 30 | | public static Guid GetMD5(this string str) |
| | | 31 | | { |
| | | 32 | | #pragma warning disable CA5351 |
| | 581 | 33 | | return new Guid(MD5.HashData(Encoding.Unicode.GetBytes(str))); |
| | | 34 | | #pragma warning restore CA5351 |
| | | 35 | | } |
| | | 36 | | } |
| | | 37 | | } |