While learning C# in school we needed to make a username-password system, for some extra points I wanted to use MD5 encryption, but after some research I found out usual md5 codes were easy to decipher. I wanted to make it a bit harder so wanted to add some strings to the begin and end of the string that was going to be encrypted. Problem is that I'm getting the "not all code paths return a value" and not sure how to fix it. (sorry for the noob question) The MD5 part works but I don't know why the encrypt part doesn't.
private string encrypt(string toEncrypt)
{
string step1 = MD5(toEncrypt + "example");
string step2 = MD5("example" + step1);
string final = MD5("example" + step2 + "example");
}
public string MD5(string input)
{
//use string hash = MD5('STRING');
//to call md5 encryption
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
byte[] hash = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for(int i=0; i < hash.Length; i++)
{
sb.Append(hash[i].ToString("x2"));
}
return sb.ToString();
}