2025-04-26 23:15:54 +00:00
|
|
|
using System.Security.Cryptography;
|
2025-04-25 20:05:55 +00:00
|
|
|
|
2025-04-26 23:15:54 +00:00
|
|
|
namespace SharpChat.Snowflake;
|
2025-04-25 20:05:55 +00:00
|
|
|
|
2025-04-26 23:15:54 +00:00
|
|
|
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);
|
2025-04-25 20:05:55 +00:00
|
|
|
}
|
|
|
|
}
|