Sage.Encryption.ServiceExtensions
1.0.0
dotnet add package Sage.Encryption.ServiceExtensions --version 1.0.0
NuGet\Install-Package Sage.Encryption.ServiceExtensions -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sage.Encryption.ServiceExtensions" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sage.Encryption.ServiceExtensions" Version="1.0.0" />
<PackageReference Include="Sage.Encryption.ServiceExtensions" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sage.Encryption.ServiceExtensions --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Sage.Encryption.ServiceExtensions, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Sage.Encryption.ServiceExtensions@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sage.Encryption.ServiceExtensions&version=1.0.0
#tool nuget:?package=Sage.Encryption.ServiceExtensions&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Sage.Encryption.ServiceExtensions
简介
Sage.Encryption.ServiceExtensions 提供了将加密服务集成到依赖注入容器的扩展方法。
主要特性
- 支持从配置中添加加密服务
- 支持自定义配置添加加密服务
- 适配 AOT 编译场景
使用示例
using Microsoft.Extensions.DependencyInjection;
using Sage.Encryption;
using Sage.Encryption.ServiceExtensions;
// 方法1:从配置中添加加密服务
var services = new ServiceCollection();
services.AddEncryptionService(configuration);
// 方法2:使用自定义配置添加加密服务
services.AddEncryptionService(options =>
{
options.Password = "your-secure-password";
options.Salt = "your-salt-value";
options.Iterations = 10000;
});
// 在服务中使用
public class DataProtectionService
{
private readonly IEncryptionService
_encryptionService;
public DataProtectionService(IEncryptionService
encryptionService)
{
_encryptionService = encryptionService;
}
public string ProtectData(string data)
{
var encrypted = _encryptionService.Encrypt
(data);
return Convert.ToBase64String(encrypted);
}
public string UnprotectData(string protectedData)
{
var bytes = Convert.FromBase64String
(protectedData);
return _encryptionService.DecryptToString
(bytes);
}
}
许可证
版权所有 © 2025 甲壳虫科技 团队。
贡献
欢迎提交问题和功能请求。 QQ Group: 1054304346
作者
甲壳虫科技
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Microsoft.Extensions.Configuration (>= 9.0.7)
- Microsoft.Extensions.DependencyInjection (>= 9.0.7)
- Microsoft.Extensions.Options (>= 9.0.7)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.7)
- Sage.Encryption (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0 | 114 | 7/16/2025 |