Experienced Elementalist
- Joined
- Jun 17, 2007
- Messages
- 208
- Reaction score
- 11
Hello! I'm having a bit of a problem with this:
I know for sure that the part of converting from String to Byte Array to String again works perfectly. However, these 2 lines do not work.
Result at the moment: (for "hello" as base string)
]A@*?K*v?q????
(My clipboard cannot handle some of the characters in this).
Result expected: (for "hello" as base string, based on PHP's function "md5("hello");")
5d41402abc4b2a76b9719d911017c592
I've Googled hashing in C# so many times, so please don't answer with "Google is your best friend" or "The search button is your best friend".
:3 Thanks!
PHP:
public static string ToMD5(string sBase)
{
byte[] baBaseBuffer = Encoding.ASCII.GetBytes(sBase);
HashAlgorithm haHasher = MD5CryptoServiceProvider.Create();
byte[] baHashBuffer = haHasher.ComputeHash(baBaseBuffer);
return Encoding.ASCII.GetString(baHashBuffer);
}
I know for sure that the part of converting from String to Byte Array to String again works perfectly. However, these 2 lines do not work.
PHP:
HashAlgorithm haHasher = MD5CryptoServiceProvider.Create();
byte[] baHashBuffer = haHasher.ComputeHash(baBaseBuffer);
Result at the moment: (for "hello" as base string)
]A@*?K*v?q????
(My clipboard cannot handle some of the characters in this).
Result expected: (for "hello" as base string, based on PHP's function "md5("hello");")
5d41402abc4b2a76b9719d911017c592
I've Googled hashing in C# so many times, so please don't answer with "Google is your best friend" or "The search button is your best friend".
:3 Thanks!