2016-10-28 22:40:15 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using MediaBrowser.Model.Cryptography;
|
|
|
|
|
|
2017-08-15 23:43:41 -07:00
|
|
|
|
namespace Emby.Server.Implementations.Cryptography
|
2016-10-28 22:40:15 -07:00
|
|
|
|
{
|
2016-11-08 11:44:23 -07:00
|
|
|
|
public class CryptographyProvider : ICryptoProvider
|
2016-10-28 22:40:15 -07:00
|
|
|
|
{
|
|
|
|
|
public Guid GetMD5(string str)
|
|
|
|
|
{
|
2016-11-08 11:44:23 -07:00
|
|
|
|
return new Guid(ComputeMD5(Encoding.Unicode.GetBytes(str)));
|
2016-10-28 22:40:15 -07:00
|
|
|
|
}
|
2016-11-03 00:14:14 -07:00
|
|
|
|
|
2016-11-08 11:44:23 -07:00
|
|
|
|
public byte[] ComputeSHA1(byte[] bytes)
|
2016-11-03 00:14:14 -07:00
|
|
|
|
{
|
|
|
|
|
using (var provider = SHA1.Create())
|
|
|
|
|
{
|
|
|
|
|
return provider.ComputeHash(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-08 11:44:23 -07:00
|
|
|
|
public byte[] ComputeMD5(Stream str)
|
2016-10-28 22:40:15 -07:00
|
|
|
|
{
|
|
|
|
|
using (var provider = MD5.Create())
|
|
|
|
|
{
|
|
|
|
|
return provider.ComputeHash(str);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-03 15:34:16 -07:00
|
|
|
|
|
2016-11-08 11:44:23 -07:00
|
|
|
|
public byte[] ComputeMD5(byte[] bytes)
|
2016-11-03 15:34:16 -07:00
|
|
|
|
{
|
|
|
|
|
using (var provider = MD5.Create())
|
|
|
|
|
{
|
|
|
|
|
return provider.ComputeHash(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-28 22:40:15 -07:00
|
|
|
|
}
|
|
|
|
|
}
|