Beispiel #1
0
        /// <summary>
        /// Creates a key used to encrypt messages.
        /// </summary>
        /// <returns>The encryption key</returns>
        private EncryptionKey GetEncryptionKey()
        {
            // We generated a symmetric key using triple DES and stored the
            // key in the configuration file for this application.

            string keyData = ConfigurationSettings.AppSettings["symmetricKey"];

            if (keyData == null)
            {
                throw new ApplicationException("Symmetric key not found.");
            }

            byte[] keyBytes            = Convert.FromBase64String(keyData);
            SymmetricEncryptionKey key = new SymmetricEncryptionKey(TripleDES.Create(), keyBytes);

            KeyInfoName keyName = new KeyInfoName();

            keyName.Value = "WSDK Sample Symmetric Key";

            key.KeyInfo.AddClause(keyName);

            return(key);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a key used to encrypt messages.
        /// </summary>
        /// <returns>The encryption key</returns>
        private EncryptionKey GetEncryptionKey()
        {

            // We generated a symmetric key using triple DES and stored the
            // key in the configuration file for this application.

            string keyData = ConfigurationSettings.AppSettings["symmetricKey"];
            if (keyData == null)
            {
                throw new ApplicationException("Symmetric key not found.");
            }

            byte[] keyBytes = Convert.FromBase64String(keyData);
            SymmetricEncryptionKey key = new SymmetricEncryptionKey(TripleDES.Create(), keyBytes);

            KeyInfoName keyName = new KeyInfoName();

            keyName.Value  = "WSDK Sample Symmetric Key";

            key.KeyInfo.AddClause(keyName);

            return key;
        }