I have this code:

Byte[] OriginalBytes;
Byte[] EncryptedBytes;
MD5 md5;

md5 = new MD5CryptoServiceProvider();
OriginalBytes = UTF8Encoding.Default.GetBytes(OriginalPassword);
EncryptedBytes = md5.ComputeHash(OriginalBytes);

return BitConverter.ToString(EncryptedBytes);

MessageBox.Show("MD5 Hash is: " + EncryptedBytes);

However I get the error

"A return keyword must not be followed by a object expression."

I'm quite new to C# so any help getting this working would be appreciated :)

I sorted it in the end using:

Byte[] OriginalBytes;
                    Byte[] EncryptedBytes;

                    MD5 md5;


                    md5 = new MD5CryptoServiceProvider();
                    OriginalBytes = ASCIIEncoding.Default.GetBytes(OriginalPassword);
                    EncryptedBytes = md5.ComputeHash(OriginalBytes);

                    foreach (byte a in EncryptedBytes)
                    {
                        if (a < 16)
                            PasswordHash += "0" + a.ToString("x");
                        else
                            PasswordHash += a.ToString("x");
                    }
                    OriginalPassword = null;

That brings back the MD5 password the same way that PHP does.

Edited 6 Years Ago by painejake: n/a

This question has already been answered. Start a new discussion instead.