.net X509Certificate2 私钥加密,公钥验证

.net X509Certificate2 私钥加密,公钥验证

公钥验证

            var cer = new X509Certificate2(path);
            if (cer != null)//获取公钥
            {
              RSACryptoServiceProvider pubkey = (RSACryptoServiceProvider)cer.PublicKey.Key;
            var isSig = pubkey.VerifyData(butys, CCB_ALG, verify);//验证信息
            }

私钥加密

   var privateCert = new X509Certificate2((path + Mango_Pfx_Path), Pfx_Pwd, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
        RSACryptoServiceProvider privateKey = (RSACryptoServiceProvider)privateCert.PrivateKey;
        RSACryptoServiceProvider privateKey1 = new RSACryptoServiceProvider();
        privateKey1.ImportParameters(privateKey.ExportParameters(true));

你可能感兴趣的:(.net)