2016-10-23 19:14:57 +00:00
|
|
|
|
using System;
|
2016-10-27 22:54:56 +00:00
|
|
|
|
using System.IO;
|
2016-10-23 19:14:57 +00:00
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using MediaBrowser.Model.Cryptography;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Common.Implementations.Cryptography
|
|
|
|
|
{
|
|
|
|
|
public class CryptographyProvider : ICryptographyProvider
|
|
|
|
|
{
|
|
|
|
|
public Guid GetMD5(string str)
|
2016-10-27 22:54:56 +00:00
|
|
|
|
{
|
|
|
|
|
return new Guid(GetMD5Bytes(str));
|
|
|
|
|
}
|
|
|
|
|
public byte[] GetMD5Bytes(string str)
|
|
|
|
|
{
|
|
|
|
|
using (var provider = MD5.Create())
|
|
|
|
|
{
|
|
|
|
|
return provider.ComputeHash(Encoding.Unicode.GetBytes(str));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public byte[] GetMD5Bytes(Stream str)
|
2016-10-23 19:14:57 +00:00
|
|
|
|
{
|
|
|
|
|
using (var provider = MD5.Create())
|
|
|
|
|
{
|
2016-10-27 22:54:56 +00:00
|
|
|
|
return provider.ComputeHash(str);
|
2016-10-23 19:14:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|