0
Hello, I am trying to run my program done in c# with Windows application, but it is giving a build error that I am not able to solve. I thank anyone who can help me ! Thanks ! ( The error is happening in the void method Decode )
using System;
using System.Linq;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Security.Cryptography;
namespace CriptografiaTrabalho
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
void Button1Click(object sender, EventArgs e)
{
textBox2.Text = Codificar(textBox1.Text);
}
void Button2Click(object sender, EventArgs e)
{
textBox3.Text = Decodificar(textBox2.Text);
}
public static string Codificar(string entrada)
{
TripleDESCryptoServiceProvider cript = new TripleDESCryptoServiceProvider();
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
try
{
if (entrada.Trim() !="")
{
string chave = "cx3f2e4ct4d2";
cript.Key = md5.ComputeHash(Encoding.Default.GetBytes(chave));
cript.Mode = CipherMode.ECB;
ICryptoTransform dencrypt = cript.CreateEncryptor();
byte[] buff = Encoding.Default.GetBytes(entrada);
return Convert.ToBase64String(dencrypt.TransformFinalBlock(buff, 0, buff.Length));
}
else
{
return "";
}
}
catch (Exception exception)
{
throw exception;
}
finally
{
cript = null;
md5 = null;
}
}
public static string Decodificar(string entrada)
{
TripleDESCryptoServiceProvider decript = new TripleDESCryptoServiceProvider();
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
try
{
if (entrada.Trim() != "")
{
string chave = "cx3f2e4ct4d2";
decript.Key = md5.ComputeHash(Encoding.Default.GetBytes(chave));
decript.Mode = CipherMode.ECB;
ICryptoTransform dencrypt = decript.CreateEncryptor();
byte[] buff = Convert.FromBase64String(entrada);
return Encoding.Default.GetString(dencrypt.TransformFinalBlock(buff, 0, buff.Length));
}
}
catch (Exception exception)
{
throw exception;
}
finally
{
decript = null;
md5 = null;
}
}
}
}
What is the build error? What is the message?
– Vinícius
Sorry about the mistake in public Static void Decode (input string) the message is (Cryptographic.MainForm.Decode(string): not all code paths return a value (CS0161)
– Limalini