2 Replies - 286 Views - Last Post: 07 December 2012 - 08:52 PM Rate Topic: -----

#1 7umper  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 29-April 12

Explain this statement, algorithm

Posted 07 December 2012 - 08:28 PM

Hi! all.
I need to make a login form with an encrytped data(user or pass), so I google for many time and found a fucntion.
But the problem is I dont understand the algorithm of each statement. Could you all explain to me?


    Private Function StringtoMD5(ByVal Content As String) As String
        Dim M5 As New System.Security.Cryptography.MD5CryptoServiceProvider
        Dim ByteString() As Byte = System.Text.Encoding.ASCII.GetBytes(Content)
        ByteString = M5.ComputeHash(ByteString)
        Dim FinalString As String = Nothing
        For Each bt As Byte In ByteString
            FinalString &= bt.ToString("x2")
        Next
        Return FinalString.ToUpper()
    End Function

New programmer
7umper (Nuii)

Is This A Good Question/Topic? 0
  • +

Replies To: Explain this statement, algorithm

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,772
  • Joined: 12-June 08

Re: Explain this statement, algorithm

Posted 07 December 2012 - 08:39 PM

Read it out loud.

line 2 - variable m4 is a MD5CryptoServiceProvider
line 3 - variable ByteString is a byte array that is filled with the variable 'Content' 's value converted to an array of bytes.
Line 4 - byte array 'ByteString' gets the hash of itself.
Line 5 - create an empty string called 'finalstring'.
Line 6 - for each byte in the byte array 'ByteString'
Line 7 - concatenate 'finalstring' the current byte after being string formatted X2 (a hexadecimal format)
Line 8 - go to the next byte
Line 9 - return the variable 'finalstring' in upper case.

http://msdn.microsof...v=vs.95%29.aspx
http://msdn.microsof...ding.ascii.aspx
http://msdn.microsof...ceprovider.aspx
Was This Post Helpful? 1
  • +
  • -

#3 7umper  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 29-April 12

Re: Explain this statement, algorithm

Posted 07 December 2012 - 08:52 PM

View Postmodi123_1, on 08 December 2012 - 10:39 AM, said:

Read it out loud.

line 2 - variable m4 is a MD5CryptoServiceProvider
line 3 - variable ByteString is a byte array that is filled with the variable 'Content' 's value converted to an array of bytes.
Line 4 - byte array 'ByteString' gets the hash of itself.
Line 5 - create an empty string called 'finalstring'.
Line 6 - for each byte in the byte array 'ByteString'
Line 7 - concatenate 'finalstring' the current byte after being string formatted X2 (a hexadecimal format)
Line 8 - go to the next byte
Line 9 - return the variable 'finalstring' in upper case.

http://msdn.microsof...v=vs.95%29.aspx
http://msdn.microsof...ding.ascii.aspx
http://msdn.microsof...ceprovider.aspx


Thanks modi123_1. I just want to understand deeply before I code a program.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1