Exemplo n.º 1
0
        public static string DeCryptString(byte[] value)
        {
            string result;

            using (RSACryptoServiceProvider RSAxml = new RSACryptoServiceProvider())
            {
                byte[] decryptedData;

                RSAxml.FromXmlString(SettingsDbConnection.PrivateKeyXml);

                decryptedData = CryptHelper.RSADecrypt(value, RSAxml.ExportParameters(true), false);

                result = CryptHelper.GetString(decryptedData);
            }

            return(result);
        }
Exemplo n.º 2
0
        static public byte[] CryptString(string value)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load("key.xml");

            byte[] encryptedData;
            byte[] dataToEncrypt = CryptHelper.GetBytes(value);

            using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
            {
                RSA.FromXmlString(doc.OuterXml);

                encryptedData = CryptHelper.RSAEncrypt(dataToEncrypt, RSA.ExportParameters(false), false);
            }

            return(encryptedData);
        }