MD5 Hashing with a key in C #

I was looking for a way to hash a given string in C # that uses a predefined key.

In my adventures over the Internet, trying to find an example, I saw many examples of MD5CryptoServiceProvider, which seem to use the default key for the machine, but none of them apply a specific key. I need to have a special key to encode data in order to synchronize it with another server. I give them the hashed string and ID number, and they use this data analysis and return a similar set to me. One way or another, to get md5 in a hash through a specific key that would be compatible with both.

I would prefer it to be done in C #, but if this is not possible with libraries, can you do this with some web languages ​​like php or asp?

Edit: I misunderstood the scenario that I was thrown into, and after a little sitting, and wondered why they would force me to use the key, which apparently wants the key to be added to the end of the line and hashed. Thus, the server can add the key that it has along with the transmitted data to ensure its real access to the computer. Anyway ... thanks to everyone ^ _ ^

Edit2: As stated in my comment below, it was the term “salting,” which I did not pay attention to. Oh, the joy of getting into something new without any indication.

+5
source share
6

MD5 - . .

. . . , , .

, - gpg , , . , , ( , , ).


: .

MD5 - - - . , , , , . MD5 , , . - . , , , MD5 " ". md5 , , .

HMAC - - . , , , - . HMAC, HMAC, HMAC , , , .

+17

MD5 - , , "" . 128- "Message Digest" ( MD ), .

+2

: MD5 - , . :

0

AES #, , . , .

0

, SymmetricAlgorithm, :

  • AesCryptoServiceProvider
  • DESCryptoServiceProvider
  • RC2CryptoServiceProvider
  • TripleDESCryptoServiceProvider
0
source

So, why does the following test run if both input lines are identical?

    [TestMethod]
    public void MD5HashTest()
    {
        var hash1 = (new MD5CryptoServiceProvider()).ComputeHash(new System.Text.ASCIIEncoding().GetBytes("now is the time for all good men."));
        var hash2 = (new MD5CryptoServiceProvider()).ComputeHash(new System.Text.ASCIIEncoding().GetBytes("now is the time for all good men."));

        Assert.AreEqual(hash1, hash2);
    }
0
source

All Articles