C# 参数字段大小?

C# 参数字段大小?,c#,C#,我通过rsacyptoserviceprovider创建非对称密钥对。我在字节[]中获得密钥对,因此可以保存它。我避免使用XML选项,以避免可能的跨平台编码问题 public byte[] CreateKeyPair() { RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); //read the key pair in byte[] RSAPara

我通过
rsacyptoserviceprovider
创建非对称密钥对。我在
字节[]
中获得密钥对,因此可以保存它。我避免使用XML选项,以避免可能的跨平台编码问题

        public byte[] CreateKeyPair()
    {
        RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

        //read the key pair in byte[]
        RSAParameters rsaKeyPair = rsa.ExportParameters(true);
        List<byte> keyPairList = new List<byte>();
        foreach (byte b in rsaKeyPair.D) { keyPairList.Add(b); }
        foreach (byte b in rsaKeyPair.DP) { keyPairList.Add(b); }
        foreach (byte b in rsaKeyPair.DQ) { keyPairList.Add(b); }
        foreach (byte b in rsaKeyPair.Exponent) { keyPairList.Add(b); }
        foreach (byte b in rsaKeyPair.InverseQ) { keyPairList.Add(b); }
        foreach (byte b in rsaKeyPair.Modulus) { keyPairList.Add(b); }
        foreach (byte b in rsaKeyPair.P) { keyPairList.Add(b); }
        foreach (byte b in rsaKeyPair.Q) { keyPairList.Add(b); }

        return keyPairList.ToArray();
    }
public byte[]CreateKeyPair()
{
RSACryptoServiceProvider rsa=新的RSACryptoServiceProvider();
//读取字节[]中的密钥对
rsacameters rsaKeyPair=rsa.ExportParameters(true);
List keyPairList=新列表();
foreach(rsaKeyPair.D中的字节b){keyPairList.Add(b);}
foreach(rsaKeyPair.DP中的字节b){keyPairList.Add(b);}
foreach(rsaKeyPair.DQ中的字节b){keyPairList.Add(b);}
foreach(rsaKeyPair.index中的字节b){keyPairList.Add(b);}
foreach(rsaKeyPair.InverseQ中的字节b){keyPairList.Add(b);}
foreach(rsaKeyPair.module中的字节b){keyPairList.Add(b);}
foreach(rsaKeyPair.P中的字节b){keyPairList.Add(b);}
foreach(rsaKeyPair.Q中的字节b){keyPairList.Add(b);}
return keyPairList.ToArray();
}
现在我想从
byte[]
转换回
rsacyptoserviceprovider

我的问题是,所有的字段每次都是固定大小的,如果是,每个字段的大小是多少,或者我应该以某种方式对它们进行划分


<>如果我序列化<代码> RsSabMudiss/Cuth>,有人能轻易地在C++中反序列化/读取结构吗?我认为不是,但无论如何值得一问……

使用PEM/DER这样的已知格式?这看起来很难看,就像用ak47射击苍蝇一样:)ak47以可靠和易于维护而闻名。