Re: MD5

From: Marre (news_at_supremelink.se)
Date: 11/22/05

  • Next message: Dominick Baier [DevelopMentor]: "Re: MD5"
    Date: Tue, 22 Nov 2005 15:25:04 +0100
    
    

    Hi Dominick!

    Thanks for youre answer. Now I get a string, but I canīt get that string
    equal with the string I receive :) I have to try it a little bit more. My
    code looks like this:

    private string checkMD5sum(string inputvalue)
    {
     // Perform a hash operation using the phrase. This will
     // generate a unique 32 character value to be used as the key.
     byte[] bytePhrase = Encoding.Default.GetBytes(inputvalue);
     MD5 md5 = new MD5CryptoServiceProvider();

     md5.ComputeHash(bytePhrase);
     byte[] result = md5.Hash;

     // Build the final string by converting each byte
     // into hex and appending it to a StringBuilder
     StringBuilder sb = new StringBuilder();
     for (int i=0;i<result.Length;i++)
     {
      sb.Append(result[i].ToString("X2"));
     }

     // And return it
     return sb.ToString();
    }

    Best regards
    Marre

    "Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com>
    wrote in message news:4580be631481398c7bd799da46c07@news.microsoft.com...
    > Hello Marre,
    >
    > this uses SHA1 for something similar - should be enough to get you
    > started...
    >
    > // Hash = H(salt, H(passphrase))
    > static void lengthExtensionHash2()
    > {
    > Console.WriteLine("Hash with anti length extension attack 2");
    >
    > string password = "secret";
    > byte[] passwordBytes = Encoding.Unicode.GetBytes(password);
    > byte[] salt = new byte[32];
    >
    > new RNGCryptoServiceProvider().GetBytes(salt);
    >
    > SHA1Managed sha = new SHA1Managed();
    >
    > byte[] hashedPasswordBytes = sha.ComputeHash(passwordBytes);
    >
    > CryptoStream cs = new CryptoStream(Stream.Null, sha,
    > CryptoStreamMode.Write);
    > cs.Write(salt, 0, salt.Length);
    > cs.Write(hashedPasswordBytes, 0, hashedPasswordBytes.Length);
    > cs.FlushFinalBlock();
    >
    > byte[] hash = sha.Hash;
    >
    > string hashString = Convert.ToBase64String(hash);
    > string saltString = Convert.ToBase64String(salt);
    >
    > Console.WriteLine("Hash: " + hashString);
    > Console.WriteLine("Salt: " + saltString);
    > }
    >
    > ---------------------------------------
    > Dominick Baier - DevelopMentor
    > http://www.leastprivilege.com
    >
    >> Hi all!
    >>
    >> I have a md5 question.
    >> I receive a md5 string created with Message-Digest algorithm and I
    >> want to
    >> create the same string in my webapplication.
    >> I have this values to go on:
    >>
    >> myMD5String = MD5(mySecretValue2 + MD5(mySecretValue1 + "some
    >> string"))
    >>
    >> myMD5String should of cource be the same as the md5 string i receive.
    >>
    >> I have no idea if I have told you enough about my problem, but someone
    >> might be able to point me to right direction :)
    >>
    >> Best regards
    >> Marre
    >
    >


  • Next message: Dominick Baier [DevelopMentor]: "Re: MD5"

    Relevant Pages

    • Re: GDI/Screen capture
      ... "Justin Rogers" wrote: ... >> Regards, ... >> Steve. ... >> lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As ...
      (microsoft.public.dotnet.framework.drawing)
    • Re: Interating over the characters in a string
      ... I have a question in regards to .Net string maniplulation. ... The problem is I have a CSV parser that will successfully parse out quoted ... pairs to reprisent a single character. ...
      (microsoft.public.dotnet.framework)
    • Re: Deletion of Empty Page in the Word Document through VBA
      ... The find string "^b" is not working. ... Regards ... "Kiruthiga" wrote: ... >>> scan each and every page and finding if any empty page is there. ...
      (microsoft.public.word.vba.general)
    • Re: CF ComboBox databinding bug?
      ... Ilya ... > The key from the lookup table is stored in the parent table unless no ... > Thanks for the info on using an object instead of a string. ... >> Best regards, ...
      (microsoft.public.dotnet.framework.compactframework)
    • Re: Emailing report data
      ... Best regards, ... "Alex Dybenko" wrote: ... >> Public Sub olSendRpt(strTo As String, strBody As String, strSubject As ... >> Dim strFileName As String, intFile As Integer, strLine As String, ...
      (microsoft.public.access.modulesdaovba)