How to generate an MD5 data from the string

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default How to generate an MD5 data from the string

    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 Guest

  2. Similar Questions and Discussions

    1. How to add a space to string data in datagrid
      hi Gurus, How to add a space to string data using the dataformatstring property ? Is there any other way to do it. Shreyas
    2. ASP Code to generate the schema of an SQL Table (field name, Data types , Size)
      Anyone has this SQL STATEMENT to traverse the User defined tables? I just need the Select Statement to get this info the rest I can handle. I...
    3. Adding pwd to data connection string
      Hi can anyone tell me how to add a password to using this connection string pls <% set conn = server.createobject ("ADODB.connection")...
    4. How to generate an invoice from data
      I need to be able to generate an invoice from an ASP page. Currently, the invoice is drawn in a web page and my client prints the page from their...
    5. Data Base connection string management
      This is the same way I handle my connection strings except I usually add the ASPNET account into my SQL server and use Windows authentication so I...
  3. #2

    Default Re: How to generate an MD5 data from the string

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

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

    Patrice
    --

    "Peter Afonin" <pva@speakeasy.net> a écrit dans le message de
    news:OBsIoDnhEHA.1568@TK2MSFTNGP09.phx.gbl...
    > 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 Guest

  4. #3

    Default Re: How to generate an MD5 data from the string

    Thank you, Patrice.

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

    Peter

    "Patrice" <nobody@nowhere.com> wrote in message
    news:OL9PaRqhEHA.712@TK2MSFTNGP09.phx.gbl...
    > And the exact problem is (how do you convert) ?
    >
    > I would suggest
    >
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/cryptosimplified.asp[/url]
    >
    > Patrice
    > --
    >
    > "Peter Afonin" <pva@speakeasy.net> a écrit dans le message de
    > news:OBsIoDnhEHA.1568@TK2MSFTNGP09.phx.gbl...
    > > 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 Guest

  5. #4

    Default Re: How to generate an MD5 data from the string


    The absolute simplest way is to use:

    string md5= System.Web.Security.FormsAuthentication.HashPasswo rdForStoringInConfigFile( 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" <pva@speakeasy.net> wrote in message news:OBsIoDnhEHA.1568@TK2MSFTNGP09.phx.gbl...
    > 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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139