Ejemplo n.º 1
0
        private string GetResult(CommonHelper.CommonEnum.EncryptEnum encryptEnum, string str, bool isEncrypt)
        {
            string result = string.Empty;

            try
            {
                switch (encryptEnum)
                {
                case CommonHelper.CommonEnum.EncryptEnum.AES:
                    XCLNetTools.Encrypt.AESEncrypt aes = new XCLNetTools.Encrypt.AESEncrypt(this.ckContainKey.Checked);
                    if (string.IsNullOrEmpty(this.txtKey.Text))
                    {
                        result = isEncrypt ? aes.Encrypt(this.txtInput.Text) : aes.Decrypt(this.txtResult.Text);
                    }
                    else
                    {
                        result = isEncrypt ? aes.Encrypt(this.txtInput.Text, this.txtKey.Text) : aes.Decrypt(this.txtResult.Text, this.txtKey.Text);
                    }
                    break;

                case CommonHelper.CommonEnum.EncryptEnum.Base64:
                    result = isEncrypt ? XCLNetTools.Encode.Base64.Base64Code(str) : XCLNetTools.Encode.Base64.Base64Decode(str);
                    break;

                case CommonHelper.CommonEnum.EncryptEnum.DES:
                    if (string.IsNullOrEmpty(this.txtKey.Text))
                    {
                        result = isEncrypt ? XCLNetTools.Encrypt.DESEncrypt.Encrypt(this.txtInput.Text) : XCLNetTools.Encrypt.DESEncrypt.Decrypt(this.txtResult.Text);
                    }
                    else
                    {
                        result = isEncrypt ? XCLNetTools.Encrypt.DESEncrypt.Encrypt(this.txtInput.Text, this.txtKey.Text) : XCLNetTools.Encrypt.DESEncrypt.Decrypt(this.txtResult.Text, this.txtKey.Text);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                result = "处理失败!";
            }
            return(result);
        }
Ejemplo n.º 2
0
 private string GetResult(CommonHelper.CommonEnum.EncryptEnum encryptEnum, string str,bool isEncrypt)
 {
     string result = string.Empty;
     try
     {
         switch (encryptEnum)
         {
             case CommonHelper.CommonEnum.EncryptEnum.AES:
                 XCLNetTools.Encrypt.AESEncrypt aes = new XCLNetTools.Encrypt.AESEncrypt(this.ckContainKey.Checked);
                 if (string.IsNullOrEmpty(this.txtKey.Text))
                 {
                     result = isEncrypt ? aes.Encrypt(this.txtInput.Text) : aes.Decrypt(this.txtResult.Text);
                 }
                 else
                 {
                     result = isEncrypt ? aes.Encrypt(this.txtInput.Text, this.txtKey.Text) : aes.Decrypt(this.txtResult.Text, this.txtKey.Text);
                 }
                 break;
             case CommonHelper.CommonEnum.EncryptEnum.Base64:
                 result = isEncrypt ? XCLNetTools.Encode.Base64.Base64Code(str) : XCLNetTools.Encode.Base64.Base64Decode(str);
                 break;
             case CommonHelper.CommonEnum.EncryptEnum.DES:
                 if (string.IsNullOrEmpty(this.txtKey.Text))
                 {
                     result = isEncrypt ? XCLNetTools.Encrypt.DESEncrypt.Encrypt(this.txtInput.Text) : XCLNetTools.Encrypt.DESEncrypt.Decrypt(this.txtResult.Text);
                 }
                 else
                 {
                     result = isEncrypt ? XCLNetTools.Encrypt.DESEncrypt.Encrypt(this.txtInput.Text, this.txtKey.Text) : XCLNetTools.Encrypt.DESEncrypt.Decrypt(this.txtResult.Text, this.txtKey.Text);
                 }
                 break;
         }
     }
     catch (Exception ex)
     {
         result = "处理失败!";
     }
     return result;
 }