2016-10-28 22:40:15 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using MediaBrowser.Model.Cryptography;
|
|
|
|
|
|
|
|
|
|
namespace Emby.Common.Implementations.Cryptography
|
|
|
|
|
{
|
|
|
|
|
public class CryptographyProvider : ICryptographyProvider
|
|
|
|
|
{
|
|
|
|
|
public Guid GetMD5(string str)
|
|
|
|
|
{
|
|
|
|
|
return new Guid(GetMD5Bytes(str));
|
|
|
|
|
}
|
|
|
|
|
public byte[] GetMD5Bytes(string str)
|
|
|
|
|
{
|
|
|
|
|
using (var provider = MD5.Create())
|
|
|
|
|
{
|
|
|
|
|
return provider.ComputeHash(Encoding.Unicode.GetBytes(str));
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-03 00:14:14 -07:00
|
|
|
|
|
|
|
|
|
public byte[] GetSHA1Bytes(byte[] bytes)
|
|
|
|
|
{
|
|
|
|
|
using (var provider = SHA1.Create())
|
|
|
|
|
{
|
|
|
|
|
return provider.ComputeHash(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 22:40:15 -07:00
|
|
|
|
public byte[] GetMD5Bytes(Stream str)
|
|
|
|
|
{
|
|
|
|
|
using (var provider = MD5.Create())
|
|
|
|
|
{
|
|
|
|
|
return provider.ComputeHash(str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|