28 lines
877 B
C#
28 lines
877 B
C#
using System;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace Jellyfin.Plugin.SRFPlay.Utilities;
|
|
|
|
/// <summary>
|
|
/// Helper class for URN-related operations.
|
|
/// </summary>
|
|
public static class UrnHelper
|
|
{
|
|
/// <summary>
|
|
/// Generates a deterministic GUID from a URN.
|
|
/// This ensures the same URN always produces the same GUID.
|
|
/// MD5 is used for non-cryptographic purposes only (generating stable IDs).
|
|
/// </summary>
|
|
/// <param name="urn">The URN to convert.</param>
|
|
/// <returns>A deterministic GUID string.</returns>
|
|
#pragma warning disable CA5351 // MD5 is used for non-cryptographic purposes (ID generation)
|
|
public static string ToGuid(string urn)
|
|
{
|
|
var hash = MD5.HashData(Encoding.UTF8.GetBytes(urn));
|
|
var guid = new Guid(hash);
|
|
return guid.ToString();
|
|
}
|
|
#pragma warning restore CA5351
|
|
}
|