How to generate an MD5 data from the string

Discussion in 'ASP .Net Security' started by Peter Afonin, Aug 20, 2004.

  1. Peter Afonin

    Peter Afonin Guest

    Hello,

    I've never been dealing with the security before. Could you please help me
    to write a code to generate an MD5 data from a string? I've been using this
    example from MSDN:

    Function MD5hash(data() As Byte) As Byte()
    ' This is one implementation of the abstract class MD5.
    Dim md5 As New MD5CryptoServiceProvider()

    Dim result As Byte() = md5.ComputeHash(data)

    Return result
    End Function

    but perhaps made a mistake converting string to byte and couldn't fix it.

    My string looks like this:

    sCRC = "avp:" & dblSum.ToString & ":" & CLng(Format(Now, "yyyyMMddHHmmss"))
    _
    & ":pa0107THOP:shp_UserID=" & sUser _
    & ":shp_Price=" & dblPrice.ToString & ":shp_PaymentNo=" _
    & CLng(Format(Now, "yyyyMMddHHmmss")) & ":shp_Term=" _
    & sTerm & ":shp_Email=" & sEmail

    I will be passing this parameter as a querystring.

    I would really appreciate your help.

    Thank you,

    --
    Peter Afonin
    Peter Afonin, Aug 20, 2004
    #1
    1. Advertising

  2. Peter Afonin

    Patrice Guest

    And the exact problem is (how do you convert) ?

    I would suggest
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/cryptosimplified.asp

    Patrice
    --

    "Peter Afonin" <> a écrit dans le message de
    news:...
    > Hello,
    >
    > I've never been dealing with the security before. Could you please help me
    > to write a code to generate an MD5 data from a string? I've been using

    this
    > example from MSDN:
    >
    > Function MD5hash(data() As Byte) As Byte()
    > ' This is one implementation of the abstract class MD5.
    > Dim md5 As New MD5CryptoServiceProvider()
    >
    > Dim result As Byte() = md5.ComputeHash(data)
    >
    > Return result
    > End Function
    >
    > but perhaps made a mistake converting string to byte and couldn't fix it.
    >
    > My string looks like this:
    >
    > sCRC = "avp:" & dblSum.ToString & ":" & CLng(Format(Now,

    "yyyyMMddHHmmss"))
    > _
    > & ":pa0107THOP:shp_UserID=" & sUser _
    > & ":shp_Price=" & dblPrice.ToString & ":shp_PaymentNo=" _
    > & CLng(Format(Now, "yyyyMMddHHmmss")) & ":shp_Term=" _
    > & sTerm & ":shp_Email=" & sEmail
    >
    > I will be passing this parameter as a querystring.
    >
    > I would really appreciate your help.
    >
    > Thank you,
    >
    > --
    > Peter Afonin
    >
    >
    Patrice, Aug 20, 2004
    #2
    1. Advertising

  3. Peter Afonin

    Peter Afonin Guest

    Thank you, Patrice.

    I'll try this, if it doesn't work I'll post my conversion here.

    Peter

    "Patrice" <> wrote in message
    news:...
    > And the exact problem is (how do you convert) ?
    >
    > I would suggest
    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/cryptosimplified.asp
    >
    > Patrice
    > --
    >
    > "Peter Afonin" <> a écrit dans le message de
    > news:...
    > > Hello,
    > >
    > > I've never been dealing with the security before. Could you please help

    me
    > > to write a code to generate an MD5 data from a string? I've been using

    > this
    > > example from MSDN:
    > >
    > > Function MD5hash(data() As Byte) As Byte()
    > > ' This is one implementation of the abstract class MD5.
    > > Dim md5 As New MD5CryptoServiceProvider()
    > >
    > > Dim result As Byte() = md5.ComputeHash(data)
    > >
    > > Return result
    > > End Function
    > >
    > > but perhaps made a mistake converting string to byte and couldn't fix

    it.
    > >
    > > My string looks like this:
    > >
    > > sCRC = "avp:" & dblSum.ToString & ":" & CLng(Format(Now,

    > "yyyyMMddHHmmss"))
    > > _
    > > & ":pa0107THOP:shp_UserID=" & sUser _
    > > & ":shp_Price=" & dblPrice.ToString & ":shp_PaymentNo=" _
    > > & CLng(Format(Now, "yyyyMMddHHmmss")) & ":shp_Term=" _
    > > & sTerm & ":shp_Email=" & sEmail
    > >
    > > I will be passing this parameter as a querystring.
    > >
    > > I would really appreciate your help.
    > >
    > > Thank you,
    > >
    > > --
    > > Peter Afonin
    > >
    > >

    >
    >
    Peter Afonin, Aug 20, 2004
    #3
  4. Peter Afonin

    PL Guest

    The absolute simplest way is to use:

    string md5= System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile( str,"MD5");

    where str is your string you want to computer the hash from and the last argument can
    be "MD5" or "SHA1"

    For more info look this up in the docs.

    PL.


    "Peter Afonin" <> wrote in message news:...
    > Hello,
    >
    > I've never been dealing with the security before. Could you please help me
    > to write a code to generate an MD5 data from a string? I've been using this
    > example from MSDN:
    >
    > Function MD5hash(data() As Byte) As Byte()
    > ' This is one implementation of the abstract class MD5.
    > Dim md5 As New MD5CryptoServiceProvider()
    >
    > Dim result As Byte() = md5.ComputeHash(data)
    >
    > Return result
    > End Function
    >
    > but perhaps made a mistake converting string to byte and couldn't fix it.
    >
    > My string looks like this:
    >
    > sCRC = "avp:" & dblSum.ToString & ":" & CLng(Format(Now, "yyyyMMddHHmmss"))
    > _
    > & ":pa0107THOP:shp_UserID=" & sUser _
    > & ":shp_Price=" & dblPrice.ToString & ":shp_PaymentNo=" _
    > & CLng(Format(Now, "yyyyMMddHHmmss")) & ":shp_Term=" _
    > & sTerm & ":shp_Email=" & sEmail
    >
    > I will be passing this parameter as a querystring.
    >
    > I would really appreciate your help.
    >
    > Thank you,
    >
    > --
    > Peter Afonin
    >
    >
    PL, Aug 24, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Afonin

    How to generate an MD5 data from the string

    Peter Afonin, Aug 20, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    481
  2. Replies:
    9
    Views:
    17,088
    John Salerno
    May 8, 2006
  3. dutche

    How to generate a md5 hash?

    dutche, Jul 20, 2005, in forum: C Programming
    Replies:
    16
    Views:
    1,871
    CBFalconer
    Jul 22, 2005
  4. Generate MD5

    , Dec 8, 2008, in forum: Java
    Replies:
    7
    Views:
    1,220
    Roedy Green
    Dec 11, 2008
  5. Peter Woodsky

    create a md5 / md5 passwd with a salt

    Peter Woodsky, Nov 20, 2008, in forum: Ruby
    Replies:
    6
    Views:
    210
    Brian Candler
    Nov 21, 2008
Loading...

Share This Page