1
0

17 lines
494 B
C#

using System.Security.Cryptography;
using System.Text;
namespace Flawless.Abstraction;
public static class HashUtility
{
public static UInt128 StringToMd5Uint128(string input)
{
ReadOnlySpan<byte> source = Encoding.UTF8.GetBytes(input);
Span<byte> destination = stackalloc byte[16];
if (MD5.HashData(source, destination) != 16) throw new InvalidOperationException("MD5 hash length is invalid.");
return BitConverter.ToUInt128(destination);
}
}