当我使用以下代码创建公钥/私钥时:
// Create the CspParameters object and set the key container
// name used to store the RSA key pair.
CspParameters cp = new CspParameters();
cp.KeyContainerName = ContainerName;
// Create a new instance of RSACryptoServiceProvider that accesses
// the key container MyKeyContainerName.
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp);如果我随后调用
rsa.Encrypt (....
OR
rsa.Decrypt(..我如何知道正在使用哪个密钥。在每种情况下使用公钥还是私钥取决于应用程序。如何确定正在使用的是哪一个?
发布于 2018-02-02 20:30:18
加密是用公钥完成的,解密是用私钥完成的。因此,只有私钥的持有者才能解密。
您不应该使用公钥进行解密,因此接口不会为您提供这样做的方法。
签名使用私钥进行加密,使用公钥+某种单向哈希逻辑进行解密,但在这种情况下,接口只允许使用特定的签名方法(SignData(..)和VerifyData(..))。
https://stackoverflow.com/questions/48580428
复制相似问题