Managed .NET (C#) utility library for working with PEM files with DER/ASN.1 encoding
Managed .NET (C#) utility library for working with PEM files with DER/ASN.1 encoding.
This project has 2 separate libraries:
RSAParameters
from/to a PEM formatted filePEM files are commonly used to exchange public or private key data.
Currently files with these headers are supported:
----- BEGIN PUBLIC KEY -----
/ ----- END PUBLIC KEY -----
----- BEGIN RSA PRIVATE KEY -----
/ ----- END RSA PRIVATE KEY -----
PM> Install-Package PemUtils
or if you only want a DER converter:
PM> Install-Package DerConverter
using (var stream = File.OpenRead(path))
using (var reader = new PemReader(stream))
{
var rsaParameters = reader.ReadRsaKey();
// ...
}
using (var stream = File.Create(path))
using (var writer = new PemWriter(stream))
{
// ...
writer.WritePublicKey(rsaParameters);
}