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

41 lines
967 B
C#
Raw Normal View History

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