Rewrite hex encoder/decoder

This commit is contained in:
Bond_009
2019-10-19 00:22:08 +02:00
parent 89a21c96c0
commit a245f5a0d4
32 changed files with 243 additions and 114 deletions

View File

@@ -2,11 +2,11 @@ using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MediaBrowser.Common;
using MediaBrowser.Common.Cryptography;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Cryptography;
using static MediaBrowser.Common.HexHelper;
namespace Emby.Server.Implementations.Library
{
@@ -122,7 +122,7 @@ namespace Emby.Server.Implementations.Library
{
return string.IsNullOrEmpty(user.EasyPassword)
? null
: ToHexString(PasswordHash.Parse(user.EasyPassword).Hash);
: Hex.Encode(PasswordHash.Parse(user.EasyPassword).Hash);
}
/// <summary>

View File

@@ -8,6 +8,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common;
using MediaBrowser.Common.Cryptography;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Net;
@@ -31,7 +32,6 @@ using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Users;
using Microsoft.Extensions.Logging;
using static MediaBrowser.Common.HexHelper;
namespace Emby.Server.Implementations.Library
{
@@ -490,7 +490,7 @@ namespace Emby.Server.Implementations.Library
{
return string.IsNullOrEmpty(user.EasyPassword)
? null
: ToHexString(PasswordHash.Parse(user.EasyPassword).Hash);
: Hex.Encode(PasswordHash.Parse(user.EasyPassword).Hash);
}
private void ResetInvalidLoginAttemptCount(User user)

View File

@@ -2304,8 +2304,10 @@ namespace Emby.Server.Implementations.LiveTv
if (provider == null)
{
throw new ResourceNotFoundException(
string.Format("Couldn't find provider of type: '{0}'", info.Type)
);
string.Format(
CultureInfo.InvariantCulture,
"Couldn't find provider of type: '{0}'",
info.Type));
}
await provider.Validate(info, validateLogin, validateListings).ConfigureAwait(false);

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Http;
@@ -19,7 +18,6 @@ using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Updates;
using Microsoft.Extensions.Logging;
using static MediaBrowser.Common.HexHelper;
namespace Emby.Server.Implementations.Updates
{
@@ -455,7 +453,7 @@ namespace Emby.Server.Implementations.Updates
{
cancellationToken.ThrowIfCancellationRequested();
var hash = ToHexString(md5.ComputeHash(stream));
var hash = Hex.Encode(md5.ComputeHash(stream));
if (!string.Equals(package.checksum, hash, StringComparison.OrdinalIgnoreCase))
{
_logger.LogError(