gpt4 book ai didi

c# - .NET,弹跳城堡 : How to save public Key then import it from a File?

转载 作者:行者123 更新时间:2023-11-30 18:42:55 25 4
gpt4 key购买 nike

情况

您好,我在我的 .NET 项目中使用充气城堡 API。到目前为止,我可以使用

随机生成私钥和公钥
RsaKeyPairGenerator g = new RsaKeyPairGenerator();
g.Init(new KeyGenerationParameters(new SecureRandom(), 1024));
AsymmetricCipherKeyPair keys = g.GenerateKeyPair();
privateKey = keys.Private;
publicKey = keys.Public;

我也可以加密/解密 byte[]

问题如何将 key 保存到文件中?保存后如何将它们导入?

最佳答案

这是我的代码项目的一部分:(谁将公钥保存到文件中)

var certif_dsa = new X509Certificate2(certificat_dsa, "密码");

var pubkey_dsa = certif_dsa.GetPublicKeyString();

StreamWriter fluxInfos_dsa = null;//le fichier de la clé publique trouver le au debug

                using (fluxInfos_dsa = new StreamWriter("CléPub.txt"))
{
string ligne = " **** Le fichier de clé publique : ***** ";

fluxInfos_dsa.WriteLine(ligne);
fluxInfos_dsa.WriteLine();
fluxInfos_dsa.WriteLine("début : ");
fluxInfos_dsa.WriteLine(pubkey_dsa);
fluxInfos_dsa.WriteLine();
fluxInfos_dsa.WriteLine();
fluxInfos_dsa.WriteLine(" Fin de la clé publique. ");


}
fluxInfos_dsa.Close();

如需更多信息,请给我发送消息至 aliah32@hotmail.fr

关于c# - .NET,弹跳城堡 : How to save public Key then import it from a File?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5210348/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com