Exemplo n.º 1
0
        /// <summary>
        /// 解密(Dpapi)
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static string Decrypt(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return("");
            }

            return(crypt.DecryptSymmetric(symmProvider, text));
        }
Exemplo n.º 2
0
        private void MessageReceived(MessageEventArgs args)
        {
            string message = args.Message;

            // TODO: Decrypt message
            CryptographyManager crypto = EnterpriseLibraryContainer.Current.GetInstance <CryptographyManager>();
            string plainText           = crypto.DecryptSymmetric(symmProvider, message);

            this.txtMessages.AppendText(
                args.Sender + " says: " + plainText + Environment.NewLine);
        }
        /// <summary>
        /// WrappingMethod wraps performs the security
        /// switch and then invokes the ThreadStart delegate.
        /// </summary>
        private void WrappingMethod()
        {
            //retrieve the user account information to which thread is
            //switched.
            if (RunAs.InheritIdentity == false)
            {
                //call the utility class to switch the current thread's security context.
                SecurityUtility su       = new SecurityUtility();
                string          password = Crypto.DecryptSymmetric("AesManaged", RunAs.Password);

                su.Switch(RunAs.User, password, RunAs.Domain);
            }
            //invoke the ThreadStart delegate object passed in
            //on the class constructor
            serviceDelegate();
        }
Exemplo n.º 4
0
 public void GetExceptionWhenUsingInvalidSymmectricCryptoParameters()
 {
     cryptographyManager.DecryptSymmetric("", "");
 }