I'm porting a project targeting net472
to netstandard
. The last System.Web
dependency I'm stuck with is HttpServerUtility.UrlTokenEncode(Byte[])
.
I found Microsoft.AspNetCore.WebUtilities
, which contains Base64UrlTextEncoder
and WebEncoders
, but those are not interchangeable with the UrlTokenEncode
/Decode
, as it appends / expects the number of =
padding characters at the end, e.g.:
var data = Encoding.UTF8.GetBytes("SO");
Convert.ToBase64String(data); // U08=
HttpServerUtility.UrlTokenEncode(data); // U081 - this is what's expected and
// the only thing UrlTokenDecode can handle
Base64UrlTextEncoder.Encode(data); // U08
WebEncoders.Base64UrlEncode(data); // U08
As far as I can tell, there are no other differences (I ran tests with random strings), but it also pulls in some other dependencies (Microsoft.Net.Http.Headers & Microsoft.Extensions.Primitives), that I don't really need in that project.
Is there any nuget package with a drop-in replacement? I'm thinking of implementing this myself, if not.