diff --git a/Manager.App/Components/Application/Dev/AuthenticationHasher.razor b/Manager.App/Components/Application/Dev/AuthenticationHasher.razor new file mode 100644 index 0000000..3f91c43 --- /dev/null +++ b/Manager.App/Components/Application/Dev/AuthenticationHasher.razor @@ -0,0 +1,14 @@ + + +SAPISID Hash generator + + + + + + + + + Generate + Clear + \ No newline at end of file diff --git a/Manager.App/Components/Application/Dev/AuthenticationHasher.razor.cs b/Manager.App/Components/Application/Dev/AuthenticationHasher.razor.cs new file mode 100644 index 0000000..2ef14fb --- /dev/null +++ b/Manager.App/Components/Application/Dev/AuthenticationHasher.razor.cs @@ -0,0 +1,30 @@ +using Manager.YouTube.Util; +using Microsoft.AspNetCore.Components; + +namespace Manager.App.Components.Application.Dev; + +public partial class AuthenticationHasher : ComponentBase +{ + private const string DefaultOrigin = "https://www.youtube.com"; + public string DatasyncId { get; set; } = ""; + public string Time { get; set; } = ""; + public string SecureCookie { get; set; } = ""; + public string Origin { get; set; } = DefaultOrigin; + + public string OutputHash { get; set; } = ""; + + private void Clear() + { + DatasyncId = ""; + Time = ""; + SecureCookie = ""; + Origin = DefaultOrigin; + OutputHash = ""; + } + + private void Hash() + { + var hashedValue= AuthenticationUtilities.GetSapisidHash(DatasyncId, SecureCookie, Origin, Time); + OutputHash = hashedValue ?? "Hash failed!"; + } +} \ No newline at end of file diff --git a/Manager.App/Components/Layout/NavMenu.razor b/Manager.App/Components/Layout/NavMenu.razor index a611661..8205a2d 100644 --- a/Manager.App/Components/Layout/NavMenu.razor +++ b/Manager.App/Components/Layout/NavMenu.razor @@ -4,4 +4,5 @@ Channels Library Playlists + Development \ No newline at end of file diff --git a/Manager.App/Components/Pages/Development.razor b/Manager.App/Components/Pages/Development.razor new file mode 100644 index 0000000..668ff32 --- /dev/null +++ b/Manager.App/Components/Pages/Development.razor @@ -0,0 +1,9 @@ +@page "/Development" +@using Manager.App.Components.Application.Dev +Development page + + + + + + \ No newline at end of file diff --git a/Manager.App/Components/Pages/Development.razor.cs b/Manager.App/Components/Pages/Development.razor.cs new file mode 100644 index 0000000..2455b75 --- /dev/null +++ b/Manager.App/Components/Pages/Development.razor.cs @@ -0,0 +1,8 @@ +using Microsoft.AspNetCore.Components; + +namespace Manager.App.Components.Pages; + +public partial class Development : ComponentBase +{ + +} \ No newline at end of file diff --git a/Manager.YouTube/Util/AuthenticationUtilities.cs b/Manager.YouTube/Util/AuthenticationUtilities.cs index a0ee689..7df18a3 100644 --- a/Manager.YouTube/Util/AuthenticationUtilities.cs +++ b/Manager.YouTube/Util/AuthenticationUtilities.cs @@ -16,13 +16,16 @@ public static class AuthenticationUtilities return new AuthenticationHeaderValue(HeaderScheme, strHash); } - public static string? GetSapisidHash(string datasyncId, string sapisid, string origin) + public static string? GetSapisidHash(string datasyncId, string sapisid, string origin, string? time = null) { if (string.IsNullOrWhiteSpace(datasyncId) || string.IsNullOrWhiteSpace(sapisid) || string.IsNullOrWhiteSpace(origin)) return null; datasyncId = datasyncId.Replace("||", ""); sapisid = Uri.UnescapeDataString(sapisid); - var time = GetTime(); + if (string.IsNullOrWhiteSpace(time)) + { + time = GetTime(); + } var sha1 = HashString($"{datasyncId} {time} {sapisid} {origin}"); var completeHash = $"{time}_{sha1}_u"; return completeHash;