sharp-chat/SharpChatCommon/Snowflake/RandomSnowflake.cs
flashwave e17aed7c25
Switched to Index brand random Snowflakes instead of SharpIds.
If you were still handling message ids as integers in an environment that can't handle signed 64-bit integers you're going to be having a fun time after this update!
2025-04-25 20:05:57 +00:00

13 lines
432 B
C#

using System.Security.Cryptography;
namespace SharpChat.Snowflake {
public class RandomSnowflake(
SnowflakeGenerator? generator = null
) {
public readonly SnowflakeGenerator Generator = generator ?? new SnowflakeGenerator();
public long Next(DateTimeOffset? at = null) {
return Generator.Next(Math.Abs(BitConverter.ToInt64(RandomNumberGenerator.GetBytes(8))), at);
}
}
}