我有一个奇怪的问题。我正在使用后面的 c# 代码开发一个 .net windows 项目。我正在尝试使用公钥/私钥加密/解密文件。自从我开始从事加密工作以来,这种情况已经发生过几次。如何让加密工作的实际问题将在稍后发布。
问题是,在单步执行我的代码时,指针退出了例程。它不会崩溃或陷入 try/catch 块。
在获取公钥的行下方的情况下,获取私钥的行不起作用。它只是跳过并返回到调用模块。
string publicKey; // gets the public key
string privateKey; // gets the private key
try
{
CspParameters cspParam = new CspParameters();
cspParam.Flags = CspProviderFlags.UseMachineKeyStore;
System.Security.Cryptography.RSACryptoServiceProvider RSA =
new System.Security.Cryptography.RSACryptoServiceProvider(cspParam);
// The key information
//from the cspParam object above can be saved via
//select the;
publicKey = RSA.ToXmlString(false); // gets the public key
privateKey = RSA.ToXmlString(true); // gets the private key
string x = publicKey;
}
catch (Exception ex)
{
clsGetMessage.DisplayError(ex);
}