本文介紹了為什么我得到“指定的算法無效"?例外的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
這是我的代碼.
X509Certificate pXCert = new X509Certificate2(@"keyStore.p12", "password");
RSACryptoServiceProvider csp = (RSACryptoServiceProvider)pXCert.PrivateKey;
string id = CryptoConfig.MapNameToOID("SHA256");
return csp.SignData(File.ReadAllBytes(filePath), id);
在最后一行我得到了異常:
On the last line I'm getting the exception:
System.Security.Cryptography.CryptographicException "指定的算法無效."
System.Security.Cryptography.CryptographicException "Invalid algorithm specified."
我做錯了什么?
更新:
id = 2.16.840.1.101.3.4.2.1
id = 2.16.840.1.101.3.4.2.1
推薦答案
.NET 代碼或您提供的 CSP 代碼沒有問題.
There is no issue with .NET code or the CSP code you provided.
您的問題是 CSP 不支持 SHA 256.您可以獲取更多信息 這里
Your problem is that CSP just doesn’t support SHA 256. You can get further information here
這篇關于為什么我得到“指定的算法無效"?例外的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!