You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/Emby.Common.Implementations/Cryptography/CryptographyProvider.cs

48 lines
1.1 KiB

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