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