Пример #1
0
        public static byte[] DecryptSymetricKeyWithCertificatePrivateKey(byte[] key)
        {
            X509Certificate2 Certificate = SSLCertificate.GetValidCertificate();
            var PrivateKey = Certificate.PrivateKey as RSACryptoServiceProvider;

            return(PrivateKey.Decrypt(key, true));
        }
Пример #2
0
        public string EncryptData(string content, out byte[] outKey)
        {
            byte[] SymetricKey = GenerateRandomicKey();
            string Encrypted   = Encrypt(content, SymetricKey);

            using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
            {
                rsa.FromXmlString(SSLCertificate.GetPublicKey());
                outKey = rsa.Encrypt(SymetricKey, true);

                return(Encrypted);
            }
        }