jellyfin-server/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs

41 lines
967 B
C#
Raw Normal View History

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