![]() |
VOOZH | about |
dotnet add package System.Formats.Asn1 --version 10.0.9
NuGet\Install-Package System.Formats.Asn1 -Version 10.0.9
<PackageReference Include="System.Formats.Asn1" Version="10.0.9" />
<PackageVersion Include="System.Formats.Asn1" Version="10.0.9" />Directory.Packages.props
<PackageReference Include="System.Formats.Asn1" />Project file
paket add System.Formats.Asn1 --version 10.0.9
#r "nuget: System.Formats.Asn1, 10.0.9"
#:package System.Formats.Asn1@10.0.9
#addin nuget:?package=System.Formats.Asn1&version=10.0.9Install as a Cake Addin
#tool nuget:?package=System.Formats.Asn1&version=10.0.9Install as a Cake Tool
Provides functionality for parsing, encoding, and decoding data using Abstract Syntax Notation One (ASN.1). ASN.1 is a standard interface description language for defining data structures that can be serialized and deserialized in a cross-platform way.
Parsing ASN.1 data:
using System.Formats.Asn1;
using System.Numerics;
// Sample ASN.1 encoded data (DER format)
byte[] asn1Data = [0x30, 0x09, 0x02, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x03];
// Create an AsnReader to parse the data
AsnReader reader = new(asn1Data, AsnEncodingRules.DER);
// Parse the sequence
AsnReader sequenceReader = reader.ReadSequence();
// Read integers from the sequence
BigInteger firstInt = sequenceReader.ReadInteger();
BigInteger secondInt = sequenceReader.ReadInteger();
BigInteger thirdInt = sequenceReader.ReadInteger();
Console.WriteLine($"First integer: {firstInt}");
Console.WriteLine($"Second integer: {secondInt}");
Console.WriteLine($"Third integer: {thirdInt}");
// First integer: 1
// Second integer: 2
// Third integer: 3
Decoding ASN.1 data using AsnDecoder:
using System.Formats.Asn1;
using System.Numerics;
using System.Text;
// Sample ASN.1 encoded data
byte[] booleanData = [0x01, 0x01, 0xFF]; // BOOLEAN TRUE
byte[] integerData = [0x02, 0x01, 0x05]; // INTEGER 5
byte[] octetStringData = [0x04, 0x03, 0x41, 0x42, 0x43]; // OCTET STRING "ABC"
byte[] objectIdentifierData = [0x06, 0x03, 0x2A, 0x03, 0x04]; // OBJECT IDENTIFIER 1.2.3.4
byte[] utf8StringData = [0x0C, 0x05, 0x48, 0x65, 0x6C, 0x6C, 0x6F]; // UTF8String "Hello"
int bytesConsumed;
bool booleanValue = AsnDecoder.ReadBoolean(booleanData, AsnEncodingRules.DER, out bytesConsumed);
Console.WriteLine($"Decoded BOOLEAN value: {booleanValue}, Bytes consumed: {bytesConsumed}");
// Decoded BOOLEAN value: True, Bytes consumed: 3
BigInteger integerValue = AsnDecoder.ReadInteger(integerData, AsnEncodingRules.DER, out bytesConsumed);
Console.WriteLine($"Decoded INTEGER value: {integerValue}, Bytes consumed: {bytesConsumed}");
// Decoded INTEGER value: 5, Bytes consumed: 3
byte[] octetStringValue = AsnDecoder.ReadOctetString(octetStringData, AsnEncodingRules.DER, out bytesConsumed);
Console.WriteLine($"Decoded OCTET STRING value: {Encoding.ASCII.GetString(octetStringValue)}, Bytes consumed: {bytesConsumed}");
// Decoded OCTET STRING value: ABC, Bytes consumed: 5
string objectIdentifierValue = AsnDecoder.ReadObjectIdentifier(objectIdentifierData, AsnEncodingRules.DER, out bytesConsumed);
Console.WriteLine($"Decoded OBJECT IDENTIFIER value: {objectIdentifierValue}, Bytes consumed: {bytesConsumed}");
// Decoded OBJECT IDENTIFIER value: 1.2.3.4, Bytes consumed: 5
string utf8StringValue = AsnDecoder.ReadCharacterString(utf8StringData, AsnEncodingRules.DER, UniversalTagNumber.UTF8String, out bytesConsumed);
Console.WriteLine($"Decoded UTF8String value: {utf8StringValue}, Bytes consumed: {bytesConsumed}");
// Decoded UTF8String value: Hello, Bytes consumed: 7
Encoding ASN.1 data:
// Create an AsnWriter to encode data
AsnWriter writer = new(AsnEncodingRules.DER);
// Create a scope for the sequence
using (AsnWriter.Scope scope = writer.PushSequence())
{
// Write integers to the sequence
writer.WriteInteger(1);
writer.WriteInteger(2);
writer.WriteInteger(3);
}
// Get the encoded data
byte[] encodedData = writer.Encode();
Console.WriteLine($"Encoded ASN.1 Data: {BitConverter.ToString(encodedData)}");
// Encoded ASN.1 Data: 30-09-02-01-01-02-01-02-02-01-03
The main types provided by this library are:
System.Formats.Asn1.AsnReaderSystem.Formats.Asn1.AsnWriterSystem.Formats.Asn1.AsnDecoderSystem.Formats.Asn1.AsnEncodingRulesSystem.Formats.Asn1 is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on System.Formats.Asn1:
| Package | Downloads |
|---|---|
|
System.Security.Cryptography.Cng
Provides cryptographic algorithm implementations and key management with Windows Cryptographic Next Generation API (CNG). Commonly Used Types: System.Security.Cryptography.RSACng System.Security.Cryptography.ECDsaCng System.Security.Cryptography.CngKey When using NuGet 3.x this package requires at least version 3.4. |
|
|
System.Security.Cryptography.OpenSsl
Provides cryptographic algorithm implementations and key management for non-Windows systems with OpenSSL. Commonly Used Types: System.Security.Cryptography.RSAOpenSsl When using NuGet 3.x this package requires at least version 3.4. |
|
|
Microsoft.Identity.Client
This package contains the binaries of the Microsoft Authentication Library for .NET (MSAL.NET). MSAL.NET makes it easy to obtain tokens from the Microsoft identity platform for developers (formerly Azure AD v2.0) signing-in users with work & school accounts, Microsoft personal accounts, and social identities via Azure AD B2C. These tokens provide access to Microsoft Cloud API and any other API secured by the Microsoft identity platform. This version supports adding authentication functionality to your .NET based clients - .NET, .NET Framework, .NET MAUI |
|
|
System.Security.Cryptography.Pkcs
Provides support for PKCS and CMS algorithms. Commonly Used Types: System.Security.Cryptography.Pkcs.EnvelopedCms |
|
|
SSH.NET
SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism. |
Showing the top 20 popular GitHub repositories that depend on System.Formats.Asn1:
| Repository | Stars |
|---|---|
|
MonoGame/MonoGame
One framework for creating powerful cross-platform games.
|
|
|
memstechtips/Winhance
Application designed to optimize, customize and enhance your Windows experience.
|
|
|
mRemoteNG/mRemoteNG
mRemoteNG is the next generation of mRemote, open source, tabbed, multi-protocol, remote connections manager.
|
|
|
unoplatform/uno
Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
|
|
|
reactiveui/refit
The automatic type-safe REST library for .NET Core, Xamarin and .NET. Heavily inspired by Square's Retrofit library, Refit turns your REST API into a live interface.
|
|
|
dotnet/machinelearning
ML.NET is an open source and cross-platform machine learning framework for .NET.
|
|
|
jstedfast/MailKit
A cross-platform .NET library for IMAP, POP3, and SMTP.
|
|
|
EduardoPires/EquinoxProject
Web Application ASP.NET 9 using Clean Architecture, DDD, CQRS, Event Sourcing and a lot of good practices
|
|
|
actions/runner
The Runner for GitHub Actions :rocket:
|
|
|
Azure/azure-powershell
Microsoft Azure PowerShell
|
|
|
sshnet/SSH.NET
SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
|
|
|
CommunityToolkit/dotnet
.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
|
|
|
Sergio0694/ComputeSharp
A .NET library to run C# code in parallel on the GPU through DX12, D2D1, and dynamically generated HLSL compute and pixel shaders, with the goal of making GPU computing easy to use for all .NET developers! 🚀
|
|
|
CommunityToolkit/Maui
The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
|
|
|
NuGetPackageExplorer/NuGetPackageExplorer
Create, update and deploy Nuget Packages with a GUI
|
|
|
OrchardCMS/Orchard
Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform. Check out the next generation of this software built on ASP.NET Core: https://github.com/OrchardCMS/OrchardCore
|
|
|
ProtonVPN/win-app
Official ProtonVPN Windows app
|
|
|
OPCFoundation/UA-.NETStandard
OPC Unified Architecture .NET Standard
|
|
|
velopack/velopack
Installer and automatic update framework for cross-platform desktop applications
|
|
|
MichaelGrafnetter/DSInternals
Directory Services Internals (DSInternals) PowerShell Module and Framework
|
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.0-preview.5.26302.115 | 1,169 | 6/9/2026 |
| 11.0.0-preview.4.26230.115 | 8,623 | 5/12/2026 |
| 11.0.0-preview.3.26207.106 | 16,986 | 4/14/2026 |
| 11.0.0-preview.2.26159.112 | 5,973 | 3/10/2026 |
| 11.0.0-preview.1.26104.118 | 7,260 | 2/10/2026 |
| 10.0.9 | 122,707 | 6/9/2026 |
| 10.0.8 | 740,483 | 5/12/2026 |
| 10.0.7 | 1,170,393 | 4/21/2026 |
| 10.0.6 | 829,556 | 4/14/2026 |
| 10.0.5 | 997,748 | 3/12/2026 |
| 10.0.4 | 98,242 | 3/10/2026 |
| 10.0.3 | 940,344 | 2/10/2026 |
| 10.0.2 | 2,305,283 | 1/13/2026 |
| 10.0.1 | 1,103,749 | 12/9/2025 |
| 9.0.17 | 49,350 | 6/9/2026 |
| 9.0.16 | 309,141 | 5/12/2026 |
| 9.0.15 | 1,147,258 | 4/14/2026 |
| 9.0.14 | 680,036 | 3/10/2026 |
| 9.0.13 | 678,550 | 2/10/2026 |
| 9.0.12 | 1,045,278 | 1/13/2026 |