WalterDependencyInjectionHelper..::..UseSymmetricEncryption<(Of <(<'T>)>)> Method
Configures the use of SymmetricEncryption with a given password for classes that require it.
This method extends IServiceCollection, enabling the integration of symmetric encryption into the .NET dependency injection framework.
Namespace:
Microsoft.Extensions.DependencyInjectionAssembly: Walter (in Walter.dll)
Syntax
public static T UseSymmetricEncryption<T>( this T service, string password ) where T : IServiceCollection
Type Parameters
- T
- The type of the service collection, constrained to IServiceCollection.
Parameters
- service
- Type: T
The instance of IServiceCollection to which the symmetric encryption configuration is added.
- password
- Type: String
The password used for symmetric encryption. This password is set as the default for all encryption operations.
Return Value
The service collection instance (T), allowing for method chaining in the configuration setup.Exceptions
| Exception | Condition |
|---|---|
| [ArgumentNullException] | Thrown if the provided password is null or empty. |
Remarks
Examples
C#
public class Startup { public void ConfigureServices(IServiceCollection services) { // Other service configurations... // Configure SymmetricEncryption with a default password services.UseSymmetricEncryption("your-secure-password"); // Continue with service configuration... } }
Use DI to get the SymmetricEncryption instance injected in your class
class MySecureStorage { private readonly SymmetricEncryption _cypher; public MySecureStorage(SymmetricEncryption cypher) { _cypher= cypher; } ... rest of your code }

