Apply suggestions from code review
more minor fixes before I do larger fixes Co-Authored-By: LogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com>
This commit is contained in:
parent
bef665be36
commit
c31b0b311b
|
@ -83,7 +83,7 @@ namespace Emby.Server.Implementations.Cryptography
|
||||||
{
|
{
|
||||||
//downgrading for now as we need this library to be dotnetstandard compliant
|
//downgrading for now as we need this library to be dotnetstandard compliant
|
||||||
//with this downgrade we'll add a check to make sure we're on the downgrade method at the moment
|
//with this downgrade we'll add a check to make sure we're on the downgrade method at the moment
|
||||||
if(method == DefaultHashMethod)
|
if (method == DefaultHashMethod)
|
||||||
{
|
{
|
||||||
using (var r = new Rfc2898DeriveBytes(bytes, salt, iterations))
|
using (var r = new Rfc2898DeriveBytes(bytes, salt, iterations))
|
||||||
{
|
{
|
||||||
|
@ -96,7 +96,7 @@ namespace Emby.Server.Implementations.Cryptography
|
||||||
|
|
||||||
public byte[] ComputeHash(string hashMethod, byte[] bytes)
|
public byte[] ComputeHash(string hashMethod, byte[] bytes)
|
||||||
{
|
{
|
||||||
return ComputeHash(hashMethod, bytes, new byte[0]);
|
return ComputeHash(hashMethod, bytes, Array.Empty<byte>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] ComputeHashWithDefaultMethod(byte[] bytes)
|
public byte[] ComputeHashWithDefaultMethod(byte[] bytes)
|
||||||
|
@ -106,7 +106,7 @@ namespace Emby.Server.Implementations.Cryptography
|
||||||
|
|
||||||
public byte[] ComputeHash(string hashMethod, byte[] bytes, byte[] salt)
|
public byte[] ComputeHash(string hashMethod, byte[] bytes, byte[] salt)
|
||||||
{
|
{
|
||||||
if(hashMethod == DefaultHashMethod)
|
if (hashMethod == DefaultHashMethod)
|
||||||
{
|
{
|
||||||
return PBKDF2(hashMethod, bytes, salt, _defaultIterations);
|
return PBKDF2(hashMethod, bytes, salt, _defaultIterations);
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
if (!user.Password.Contains("$"))
|
if (!user.Password.Contains("$"))
|
||||||
{
|
{
|
||||||
string hash = user.Password;
|
string hash = user.Password;
|
||||||
user.Password = String.Format("$SHA1${0}", hash);
|
user.Password = string.Format("$SHA1${0}", hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.EasyPassword != null && !user.EasyPassword.Contains("$"))
|
if (user.EasyPassword != null && !user.EasyPassword.Contains("$"))
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace MediaBrowser.Model.Cryptography
|
||||||
for (int i = 0; i < byteString.Length; i += 2)
|
for (int i = 0; i < byteString.Length; i += 2)
|
||||||
{
|
{
|
||||||
// TODO: NetStandard2.1 switch this to use a span instead of a substring.
|
// TODO: NetStandard2.1 switch this to use a span instead of a substring.
|
||||||
bytes.Add(Convert.ToByte(byteString.Substring(i, 2),16));
|
bytes.Add(Convert.ToByte(byteString.Substring(i, 2), 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytes.ToArray();
|
return bytes.ToArray();
|
||||||
|
@ -133,7 +133,7 @@ namespace MediaBrowser.Model.Cryptography
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string outString = "$" +_id;
|
string outString = "$" + _id;
|
||||||
string paramstring = SerializeParameters();
|
string paramstring = SerializeParameters();
|
||||||
if (!string.IsNullOrEmpty(paramstring))
|
if (!string.IsNullOrEmpty(paramstring))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user