Skip to content

Commit 0fe2150

Browse files
committed
Replaced WebEncoders with Base64Url
1 parent 7b7a840 commit 0fe2150

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/ImageWizard.Client/Builder/DeliveryTypeExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// MIT License
44

55
using Microsoft.AspNetCore.Hosting;
6-
using Microsoft.AspNetCore.WebUtilities;
76
using Microsoft.Extensions.DependencyInjection;
87
using Microsoft.Extensions.FileProviders;
8+
using System.Buffers.Text;
99
using System.Security.Cryptography;
1010
using System.Text;
1111

@@ -40,9 +40,9 @@ public static IFilter FetchLocalFile(this ILoader imageBuilder, string path, int
4040

4141
SHA256.HashData(Encoding.UTF8.GetBytes(hash), hashBufferSpan);
4242

43-
string hashBase64 = WebEncoders.Base64UrlEncode(hashBufferSpan);
43+
string hashBase64 = Base64Url.EncodeToString(hashBufferSpan);
4444

45-
path += $"?v={hashBase64.AsSpan(0, maxVersionLength)}";
45+
path = $"{path}?v={hashBase64.AsSpan(0, maxVersionLength)}";
4646

4747
return imageBuilder.LoadData("fetch", path);
4848
}

src/ImageWizard.Client/Builder/ImageFilterExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// MIT License
44

55
using ImageWizard.Utils;
6-
using Microsoft.AspNetCore.WebUtilities;
6+
using System.Buffers.Text;
77
using System.Text;
88

99
namespace ImageWizard.Client;
@@ -202,7 +202,7 @@ public static Image DrawText(this Image image, string text, int? size = null, do
202202
if (useBase64Url)
203203
{
204204
byte[] buffer = Encoding.UTF8.GetBytes(text);
205-
string base64Url = WebEncoders.Base64UrlEncode(buffer);
205+
string base64Url = Base64Url.EncodeToString(buffer);
206206

207207
builder.Add($"text={base64Url}");
208208
}

src/ImageWizard.Utils/Signature/HMACSHA256UrlSignature.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// MIT License
44

55
using Microsoft.AspNetCore.Http;
6-
using Microsoft.AspNetCore.WebUtilities;
76
using Microsoft.Extensions.Caching.Memory;
87
using Microsoft.Extensions.Options;
8+
using System.Buffers.Text;
99
using System.Security.Cryptography;
1010
using System.Text;
1111

@@ -88,7 +88,7 @@ public string Encrypt(byte[] key, ImageWizardRequest request)
8888
HMACSHA256.HashData(key, inputBuffer, hashBuffer);
8989

9090
//convert to Base64Url
91-
string keyBase64Url = WebEncoders.Base64UrlEncode(hashBuffer);
91+
string keyBase64Url = Base64Url.EncodeToString(hashBuffer);
9292

9393
//add signature to cache
9494
_cache.Set(input, keyBase64Url, new MemoryCacheEntryOptions()

0 commit comments

Comments
 (0)