이상한 문제가 있습니다. 나는 .NET 윈도우 프로젝트에서 C# 코드를 사용하여 작업 중이다. 공공/개인 키를 사용하여 파일을 암호화/해독하려고합니다. 암호화 작업을 시작한 이후로 몇 차례 나 이런 일이있었습니다. 암호화를 작동시키는 실제 문제는 나중에 또 다른 게시가 될 것입니다..Net 건너 뛰기 코드
문제는 내 코드를 단계별로 실행하는 동안 포인터가 루틴을 종료한다는 것입니다. try/catch 블록에서 충돌하거나 잡히지 않습니다.
아래의 경우 공개 키를 얻으려는 줄은 작동하지만 개인 키를 가져 오는 줄은 그렇지 않습니다. 그냥 건너 뛰고 호출 모듈로 돌아갑니다. 의 PrivateKey가 임의의 장소에서 사용되지 않기 때문에
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);
}
말하기 어렵지만 권한 (개인 키에 대한 권한이없는 ASP.NET 프로세스)에 문제가있는 것으로 의심됩니다. 예외에서 파생되지 않은 예외가 throw되었을 수 있습니다. – sdcoder
Windows Forms 또는 ASP.NET을 의미합니까? Windows 폼에는 코드 숨김이 없습니다. –
Visual Studio의 Windows 폼입니다. –