INNER CODE UNIT · C#
PemFormatUtil
stulzq/RSAExtensions · src/RSAExtensions/PemFormatUtil.cs:9
internal class PemFormatUtil
{
public static string GetPublicKeyFormat(RSAKeyType type, string publicKey)
{
return type switch
{
RSAKeyType.Pkcs1 => GetPkcs1PublicKeyFormat(publicKey),
RSAKeyType.Pkcs8 => GetPkcs8PublicKeyFormat(publicKey),
_ => throw new Exception($"Public key type {type.ToString()} does not support pem formatting.")
};
}
public static string GetPrivateKeyFormat(RSAKeyType type, string privateKey)
{
return type switch
{
RSAKeyType.Pkcs1 => GetPkcs1PrivateKeyFormat(privateKey),
RSAKeyType.Pkcs8 => GetPkcs8PrivateKeyFormat(privateKey),