0

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 :)

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by painejake
0

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 by painejake: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.