WalterCypherDependencyInjectionHelper..::..AddCypherDefaults<(Of <(<'T>)>)> Method
Configures the CypherDefaults in the application's service collection,
allowing for custom encryption settings to be applied across the application.
Namespace:
Microsoft.Extensions.DependencyInjectionAssembly: Walter.Cypher (in Walter.Cypher.dll)
Syntax
public static T AddCypherDefaults<T>( this T services, Nullable<Action<CypherDefaults>> setup ) where T : IServiceCollection
Type Parameters
- T
- The type of the service collection, typically IServiceCollection.
Parameters
- services
- Type: T
The service collection to which the encryption defaults will be added.
- setup
- Type: Nullable<(Of <(<'Action<(Of <(<'CypherDefaults>)>)>>)>)>
An action to configure the CypherDefaults instance used for encryption settings.
Return Value
The original IServiceCollection instance, for method chaining.Examples
Using a fixed password
public void ConfigureServices(IServiceCollection services) { services.AddCypherDefaults(options => { options.DefaultPassword = "customPassword"; options.HashMethod = HashMethod.SHA512; }); }
Using the domain name allowing to share encrypted files between devices on the same domain
public void ConfigureServices(IServiceCollection services) { services.AddCypherDefaults(options => { options.DefaultPassword = Environment.UserDomainName; options.HashMethod = HashMethod.SHA512; }); }