diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index d7f6ad69c0..d909aff8ad 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -1399,6 +1399,34 @@ namespace OpenSim.Framework return uuid; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static UUID ComputeShake128UUID(string src) + { + return ComputeShake128UUID(Encoding.ASCII.GetBytes(src)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static UUID ComputeShake128UUID(ReadOnlySpan src) + { + byte[] ret; + UUID uuid; + if(Shake128.IsSupported) + { + ret = Shake128.HashData(src, 16); + uuid = new(ret, 0); + } + else + { + ret = SHA1.HashData(src); + uuid = new(ret, 2); + } + uuid.c &= 0x0fff; + uuid.c |= 0x5000; + uuid.d &= 0x3f; + uuid.d |= 0x80; + return uuid; + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string AESEncrypt(ReadOnlySpan secret, ReadOnlySpan plainText) {