Asgard.Tools 3.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Asgard.Tools --version 3.1.0
                    
NuGet\Install-Package Asgard.Tools -Version 3.1.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="Asgard.Tools" Version="3.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Asgard.Tools" Version="3.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Asgard.Tools" />
                    
Project file
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 Asgard.Tools --version 3.1.0
                    
#r "nuget: Asgard.Tools, 3.1.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 Asgard.Tools@3.1.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=Asgard.Tools&version=3.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Asgard.Tools&version=3.1.0
                    
Install as a Cake Tool

Asgard.Tools

Asgard.Tools 是一个包含多种实用工具的 .NET 库,旨在简化开发过程中的常见任务,如加密、压缩和枚举处理。

项目结构

Asgard.Tools/
├── Asgard.Tools.csproj
├── AuthKVToolsMethod.cs
├── BaseEncryptionTools.cs
├── BrotliUTF8.cs
├── EnumExtendsMethods.cs
└── Wildcard.cs

核心功能

加密工具 (AuthKVToolsMethod.cs)

  • CreateNewAesKeyAndVi: 创建新的 AES 加密密钥和 IV。
  • CreateNewHMACSHA256Key: 创建新的 HMACSHA256 密钥。

基础加密工具 (BaseEncryptionTools.cs)

  • SetKeyAndIV: 设置 AES 密钥和 IV。
  • Md5: 使用 MD5 对字符串进行加密。
  • EncryptStringToString_Aes: 使用 AES 加密字符串。
  • DecryptStringFromStr_Aes: 使用 AES 解密字符串。

Brotli 压缩工具 (BrotliUTF8.cs)

  • Compress: 压缩字符串或字节数组。
  • CompressHightLevel: 使用高压缩级别压缩字符串或字节数组。
  • Decompress: 解压缩字节数组。
  • GetString: 解压缩字节数组并返回字符串。

枚举扩展方法 (EnumExtendsMethods.cs)

  • GetEnumDescriptionOriginal: 获取枚举成员的描述。

通配符匹配工具 (Wildcard.cs)

  • IsMatch: 判断文本是否匹配给定的通配符模式。

使用说明

安装

可以通过 NuGet 安装 Asgard.Tools:

dotnet add package Asgard.Tools

示例

AES 加密和解密
using Asgard.Tools;

var (key, iv) = AuthKVToolsMethod.CreateNewAesKeyAndVi();
BaseEncryptionTools.SetKeyAndIV(key, iv);

string originalText = "Hello, Asgard!";
string encryptedText = BaseEncryptionTools.EncryptStringToString_Aes(originalText);
string decryptedText = BaseEncryptionTools.DecryptStringFromStr_Aes(encryptedText);

Console.WriteLine($"Original: {originalText}");
Console.WriteLine($"Encrypted: {encryptedText}");
Console.WriteLine($"Decrypted: {decryptedText}");
Brotli 压缩和解压缩
using Asgard.Tools;

string text = "This is a sample text to compress.";
byte[] compressed = BrotliUTF8.Compress(text);
string decompressed = BrotliUTF8.GetString(compressed);

Console.WriteLine($"Original: {text}");
Console.WriteLine($"Compressed: {Convert.ToBase64String(compressed)}");
Console.WriteLine($"Decompressed: {decompressed}");
枚举扩展方法
using Asgard.Tools;
using System.ComponentModel;

public enum SampleEnum
{
    [Description("First Option")]
    FirstOption,

    [Description("Second Option")]
    SecondOption,

    ThirdOption
}

SampleEnum value = SampleEnum.FirstOption;
string description = value.GetEnumDescriptionOriginal();

Console.WriteLine(description); // 输出: First Option
通配符匹配
using Asgard.Tools;

bool match1 = Wildcard.IsMatch("hello-world", "hello-*");
bool match2 = Wildcard.IsMatch("hello-world", "hi-*");

Console.WriteLine(match1); // 输出: True
Console.WriteLine(match2); // 输出: False

许可证

MIT License

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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.
  • net8.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Asgard.Tools:

Package Downloads
Asgard.Hoenir

Asgard.Hoenir是一个轻量级、高性能的事件驱动消息总线系统,支持进程内通信和A2A(Agent-to-Agent)通信。基于现有事件总线架构,通过最小化修改实现A2A通信能力。

Asgard.Extends.Json

Asgard.Extends.Json 是 Asgard 框架的一部分,提供了一些常用的 `System.Text.Json` 扩展功能,包括自定义的转换器(Converters)。

Asgard.Extends.AspNetCore

Asgard.Extends.AspNetCore 是Asgard框架对于Asp.Net core 的封装核心,是一个抽象与辅助函数对应的层

Asgard.Hosts.AspNetCore

Asgard.Hosts.AspNetCore 提供基于 ASP.NET Core 的宿主层实现,负责应用启动与依赖注入引导、通用中间件与管道配置、端点路由、gRPC 与 Swagger 集成,以及与 Asgard 框架模块(日志、配置、扩展等)的托管适配。兼容 .NET 8,面向可扩展的微服务与 Web 应用托管。

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.0-preview.1 57 2/26/2026
3.1.9 204 1/16/2026
3.1.8 192 1/15/2026
3.1.7 299 12/22/2025
3.1.6 536 12/11/2025
3.1.5 329 12/7/2025
3.1.4 790 12/2/2025
3.1.2 382 11/30/2025
3.1.1 378 11/30/2025
3.1.0 356 11/22/2025
3.0.2 444 11/17/2025
3.0.1 349 11/14/2025
3.0.0 346 11/5/2025