-
Notifications
You must be signed in to change notification settings - Fork 184
/
Copy pathCrawlExtension.cs
44 lines (38 loc) · 1.3 KB
/
CrawlExtension.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CrawlExtension.cs" company="pzcast">
// (C) 2015 pzcast. All rights reserved.
// </copyright>
// <summary>
// The crawl extension.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace SimpleCrawler
{
using System;
using System.Security.Cryptography;
using System.Text;
/// <summary>
/// The crawl extension.
/// </summary>
public static class CrawlExtension
{
#region Public Methods and Operators
/// <summary>
/// The get unique identifier.
/// </summary>
/// <param name="urlInfo">
/// The url info.
/// </param>
/// <returns>
/// The <see cref="ulong"/>.
/// </returns>
public static ulong GetUniqueIdentifier(this UrlInfo urlInfo)
{
byte[] bytes = Encoding.Default.GetBytes(urlInfo.UrlString);
var service = new MD5CryptoServiceProvider();
byte[] hashValue = service.ComputeHash(bytes);
return BitConverter.ToUInt64(hashValue, 0);
}
#endregion
}
}