jellyfin-server/MediaBrowser.Common.Implementations/Cryptography/CryptographyProvider.cs
2016-10-27 18:54:56 -04:00

31 lines
783 B
C#

using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using MediaBrowser.Model.Cryptography;
namespace MediaBrowser.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));
}
}
public byte[] GetMD5Bytes(Stream str)
{
using (var provider = MD5.Create())
{
return provider.ComputeHash(str);
}
}
}
}