using System.Security.Cryptography;
using e_suite.Modules.UserManager.Utils;

namespace e_suite.Modules.UserManager.Facade;

public class RandomNumberGeneratorFacade : IRandomNumberGenerator
{
    private readonly RandomNumberGenerator _randomNumberGenerator;
    
    public RandomNumberGeneratorFacade()
    {
        _randomNumberGenerator = RandomNumberGenerator.Create();
    }

    public void GetBytes(byte[] randomBytes)
    {
        _randomNumberGenerator.GetBytes(randomBytes);
    }

    public string GetRandomString(int length)
    {
        var randomBytes = new byte[length];
        _randomNumberGenerator.GetBytes(randomBytes);

        var key = Base32.Encode(randomBytes);
        return key;
    }
}