1using System.Buffers.Binary;
2using System.Security.Cryptography;
16 private static long last = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() * 1_000;
31 public static long New() => Interlocked.Increment(ref last);
59 ArgumentException.ThrowIfNullOrWhiteSpace(scope);
60 ArgumentException.ThrowIfNullOrWhiteSpace(value);
61 var bytes = SHA256.HashData(Encoding.UTF8.GetBytes(scope +
"\0" + value));
62 return (BinaryPrimitives.ReadInt64LittleEndian(bytes) &
long.MaxValue) is var result && result != 0 ? result : 1;
Creates positive 64-bit identifiers for new objects or repeatable external imports.
static long FromStableValue(string scope, string value)
Derives a deterministic positive identifier from a caller-controlled namespace and stable value.
static long New()
Creates a positive, process-unique identifier for a new deck, note type, note, or card.