使用这段代码加载私钥,提示系统找不到指定文件是为何?
我的代码
protected string sign(string message)
2{
3 // 需去除私钥文件中的-----BEGIN/END PRIVATE KEY-----
4 string privateKey = "MIIEvgIBADANBgkqhkiG...30HBe+GD1tntZgf6I1Y0ZpHZ";
5 byte[] keyData = Convert.FromBase64String(privateKey);
6 using (CngKey cngKey = CngKey.Import(keyData, CngKeyBlobFormat.Pkcs8PrivateBlob))
7 using (RSACng rsa = new RSACng(cngKey))
8 {
9 byte[] data = System.Text.Encoding.UTF8.GetBytes(message);
10 return Convert.ToBase64String(rsa.SignData(data, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1));
11 }
12}