Closed leyou240 closed 4 years ago
修改此方法运行成功!我提个pr
/// <summary>
/// Create an RSA key
/// </summary>
/// <param name="rsa">rsa</param>
/// <param name="includePrivate"></param>
/// <returns></returns>
public static RSAKey CreateRsaKey(RSA rsa, bool includePrivate = true)
{
Check.Argument.IsNotNull(rsa, nameof(rsa));
string publicKey = rsa.ToJsonString(false);
var rsaKey = new RSAKey()
{
PublicKey = publicKey,
Exponent = rsa.ExportParameters(false).Exponent.ToHexString(),
Modulus = rsa.ExportParameters(false).Modulus.ToHexString()
};
if (includePrivate)
{
string privateKey = rsa.ToJsonString(true);
rsaKey.PrivateKey = privateKey;
}
return rsaKey;
}
非常感谢,已经合并了。最近忙于其他项目,这边来看的少了,抱歉抱歉。
请问我的使用方式有问题吗?异常如下 Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException : 该项不存在。 at System.Security.Cryptography.CngKeyLite.ExportKeyBlob(SafeNCryptKeyHandle keyHandle, String blobType) at System.Security.Cryptography.RSAImplementation.RSACng.ExportKeyBlob(Boolean includePrivateParameters) 代码如下