Exemplo n.º 1
0
 private void btnDecrypt_Click(object sender, EventArgs e)
 {
     if (CheckTextBox())
     {
         var    entryStr = txtEncrypt.Text;
         string key      = txtKey.Text;
         try
         {
             if (cbBase64.Checked)
             {
                 byte[] bytes = FormatString.FromBase64String(entryStr);
                 txtDecrypt.Text = Encoding.Default.GetString(DES3.Decrypt(bytes, key));
             }
             if (cbHex16.Checked)
             {
                 byte[] bytes = FormatString.Hex_16To2(entryStr);
                 txtDecrypt.Text = Encoding.Default.GetString(DES3.Decrypt(bytes, key));
             }
         }
         catch (Exception ex)
         {
             txtDecrypt.Text = ex.Message;
         }
     }
 }
Exemplo n.º 2
0
        public static JsonMessage DES3Decrypt(string text, string key)
        {
            JsonMessage jsonMessage = new JsonMessage();

            if (string.IsNullOrEmpty(text))
            {
                jsonMessage.Flag    = false;
                jsonMessage.Message = "解密内容不能为空";
                return(jsonMessage);
            }
            try {
                jsonMessage.Flag = true;
                if (string.IsNullOrEmpty(key))
                {
                    key = s_key;
                }
                jsonMessage.Data = DES3.Decrypt(text, key);
            }
            catch (Exception ex) {
                jsonMessage.Flag    = false;
                jsonMessage.Message = ex.Message;
            }
            return(jsonMessage);
        }