aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Common/Utilities/UInt128Utils.cs
blob: af8521b4e9fbedad8adfe7a177654f3e7439524f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using System;
using System.Globalization;

namespace Ryujinx.Common.Utilities
{
    public static class UInt128Utils
    {
        public static UInt128 FromHex(string hex)
        {
            return new UInt128(ulong.Parse(hex.AsSpan(0, 16), NumberStyles.HexNumber), ulong.Parse(hex.AsSpan(16), NumberStyles.HexNumber));
        }

        public static UInt128 CreateRandom()
        {
            return new UInt128((ulong)Random.Shared.NextInt64(), (ulong)Random.Shared.NextInt64());
        }
    }
}