using Microsoft.Extensions.Logging; using System; using System.Linq; namespace ManagerService.Services { public interface IHexIdGeneratorService { string GenerateHexId(); // Génère un ID hexadécimal unique //string GenerateMongoObjectId(); // (Optionnel) Génère un vrai ObjectId MongoDB } public class HexIdGeneratorService : IHexIdGeneratorService { private readonly Random _random = new Random(); // Génération d'un ID hexadécimal basé sur des bytes aléatoires public string GenerateHexId() { byte[] buffer = new byte[12]; // 12 bytes → 24 caractères hex _random.NextBytes(buffer); return string.Concat(buffer.Select(b => b.ToString("x2"))); } // Génération d'un ObjectId MongoDB (facultatif) /*public string GenerateMongoObjectId() { return ObjectId.GenerateNewId().ToString(); }*/ } }