23 lines
747 B
C#
23 lines
747 B
C#
using LiteCharms.Features.Hasher;
|
|
using LiteCharms.Features.Hasher.Configuration;
|
|
|
|
namespace LiteCharms.Features.Extensions;
|
|
|
|
public static class Hash
|
|
{
|
|
public const string HasherConfigSectionName = "HasherSettings";
|
|
|
|
public static IServiceCollection AddHashServices(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
services.Configure<HasherSettings>(configuration.GetSection(HasherConfigSectionName));
|
|
|
|
var settings = configuration.GetSection(HasherConfigSectionName).Get<HasherSettings>();
|
|
|
|
services.AddSingleton<IHashids>(_ =>
|
|
new Hashids(settings!.Salt, minHashLength: settings.MinHashLength));
|
|
|
|
services.AddSingleton<HashService>();
|
|
|
|
return services;
|
|
}
|
|
} |